[Cython] array assignment
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Sat Oct 11 16:31:50 CEST 2008
Robert Bradshaw wrote:
> On Oct 11, 2008, at 7:17 AM, Dag Sverre Seljebotn wrote:
>
>> Dag Sverre Seljebotn wrote:
>>> Dag Sverre Seljebotn wrote:
>>>
>>>> What do I propose instead?
>>>> a) That the reference-counted heap-allocated array stuff in the
>>>> wiki
>>>> is implemented first (with a list constructor). So the thing gets
>>>> the
>>>> semantics of a reference counted array, constructed again each
>>>> time it
>>>> is assigned (very similar to a Python list).
>>>>
>>>> b) That simple cases (where the pointer is never reassigned or
>>>> copied,
>>>> only written/read to/from by indexing) are then optimized to use
>>>> stack
>>>> allocation instead.
>>>>
>>> First and foremost the point now is to .
>> Sorry! I meant: The point now was to argue for postponing the decision
>> for later and disable it in the upcoming release.
>>
>> I'd settle for disabling any "literal assignment" to the pointer
>> outside
>> of the declaration though, then I'd be back to "not worrying". (One
>> could also disable it only inside loops, but that is too ugly and
>> inconsistent.)
>
> I'm OK with only allowing it outside of declarations (and even
> better, only to an array type), but don't know if I'll have time to
> do that anytime soon.
I don't understand? Do you mean the opposite, i.e only allowing it
inside of declarations?
Anyway, the (final and realistic) proposal was:
cdef int* a = [1, 2, 3] # ok!
while
cdef int* a
a = [1, 2, 3] # not ok!
At least for this release (adding features is easier than removing).
This absolutely shouldn't be more than half an hour, it is just about
throwing up a compiler error in the right transform. If you're +1 to
this but don't have the time I could have a look during next week. Have
you decided on a timeframe for the release?
--
Dag Sverre
More information about the Cython-dev
mailing list