[Cython] local variable handling in generators

Vitja Makarov vitja.makarov at gmail.com
Mon May 23 21:33:36 CEST 2011


2011/5/23 Stefan Behnel <stefan_ml at behnel.de>:
>
> However, once we really know which values change between yield calls, i.e.
> which ones need to be stored away, it will actually be less expensive in
> most cases. We currently pay the indirection penalty for each access, even
> read access, whereas the C compiler can then keep important variables in
> registers and only write them back once per yield.
>

I think that all not NULL variables should be saved/restored inside yield.
I can not really track changes only assignments.

for i in a:
    yield i  # j is NULL here
for j in b:
    yield j # a, b, i ,j should be saved/restored

-- 
vitja.


More information about the cython-devel mailing list