Re: Re: Accessing a pointer's value in Cython
Robert Bradshaw <robertwb <at> math.washington.edu>
2010-07-21 18:47:01 GMT
On Fri, Jan 8, 2010 at 8:15 AM, Vogon <jusa.sj <at> gmail.com> wrote:
> A concise answer. Thank you.
To elaborate, Python already has meaning attached to the prefix *
operator (packing tuples). The index notation gets annoying, but
writing Cython is (or at least should be) more like writing Python
than writing C.
- Robert
> On Jan 8, 5:05 pm, Dag Sverre Seljebotn <da... <at> student.matnat.uio.no>
> wrote:
>> On Fri, 2010-01-08 at 06:48 -0800, Vogon wrote:
>> > Hi,
>>
>> > Is there an alternative to the following syntax of accessing a
>> > pointer's value:
>>
>> > cdef int i = 10
>> > cdef int* ptr = &i
>>
>> > ptr[0] = 5 # value of i becomes 5
>>
>> > # *ptr = 5 # does not work
>>
>> > print(ptr[0])
>>
>> > The array indexing syntax becomes a bit tedious after a while,
>> > especially when I need to modify hundreds of pointer values.
>>
(Continue reading)