[Cython] Assignments in cdefs
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Sun Jul 20 21:04:52 CEST 2008
Dag Sverre Seljebotn wrote:
> Stefan Behnel wrote:
>> Hi,
>>
>> Dag Sverre Seljebotn wrote:
>>> Stefan Behnel wrote:
>>>> What about code like this:
>>>>
>>>> def test(a):
>>>> cdef int c
>>>> if a:
>>>> c = 1
>>>> if not a:
>>>> c = 2
>>>>
>>>> How would you know what is a "first assignment" here? And what would you gain
>>>> from your ref-counting optimisation in this case?
>>> As for the example, it is a "best-effort" thing. If no assignments are
>>> flagged as first, then the optimization just doesn't happen, which is
>>> the likely outcome of your example.
>> Then what exactly is your "ref-counting optimisation" doing? Can you give me a
>> code example?
>
> It makes "cdef int x = 3" behave as before, no more or less. Just
> refactoring the code so that buffer worked. I needed to put the stuff
> that handled the difference in refcounting somewhere, and that somewhere
> leaves a hole in which to plug further improvements, so it was a natural
> name, but it doesn't mean that it is more optimized than it used to be.
>
Sorry! I meant
cdef MyExtensionsType a = x
(as int isn't refcounted...). Hmm, I guess that's where the confusion
comes from; would tend to make everything I've said unintelligible.
--
Dag Sverre
More information about the Cython-dev
mailing list