Re: [Cython] Scope resolution in a Visitor

2011-05-23 Thread Stefan Behnel
Romain Guillebert, 23.05.2011 20:33: I'm doing the PyPy backend for Cython Summer of Code project and I would like to know if there is a way of getting the AST Node responsible for the declaration of a variable. For example : def func(): def func(): pass func() In the situa

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Vitja Makarov, 23.05.2011 21:33: 2011/5/23 Stefan Behnel: 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, w

Re: [Cython] local variable handling in generators

2011-05-23 Thread Vitja Makarov
2011/5/23 Stefan Behnel : > > 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

Re: [Cython] local variable handling in generators

2011-05-23 Thread Vitja Makarov
2011/5/23 Robert Bradshaw : >> >> Then again, "del x" would be a more obvious way to spell this ... > > And then setting it to NULL would actually be correct. > That is already done ;) But usually you wouldn't use del statement in your code. > In any case, I'm -1 to deleting references once their

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Robert Bradshaw, 23.05.2011 20:09: In any case, I'm -1 to deleting references once their no longer used, we must wait 'till the end of the function, and I'm not sure the savings would be that great either. Agreed. In terms of packing/unpacking the variables onto the local C stack, until we h

[Cython] Scope resolution in a Visitor

2011-05-23 Thread Romain Guillebert
Hi I'm doing the PyPy backend for Cython Summer of Code project and I would like to know if there is a way of getting the AST Node responsible for the declaration of a variable. For example : def func(): def func(): pass func() In the situation where I'm currently traversing th

Re: [Cython] local variable handling in generators

2011-05-23 Thread Robert Bradshaw
On Mon, May 23, 2011 at 2:57 AM, Stefan Behnel wrote: > Stefan Behnel, 23.05.2011 11:29: >> >> Stefan Behnel, 23.05.2011 11:15: >>> >>> Vitja Makarov, 23.05.2011 10:50: 2011/5/23 Stefan Behnel: > > I'm fine with deallocating variables that are no longer used after the > user

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Stefan Behnel, 23.05.2011 11:29: Stefan Behnel, 23.05.2011 11:15: Vitja Makarov, 23.05.2011 10:50: 2011/5/23 Stefan Behnel: I'm fine with deallocating variables that are no longer used after the user explicitly assigned None to them (i.e. replace the None assignment by a simple "DECREF + set t

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Vitja Makarov, 23.05.2011 11:24: 2011/5/23 Stefan Behnel: Vitja Makarov, 23.05.2011 10:50: 2011/5/23 Stefan Behnel: Vitja Makarov, 23.05.2011 10:13: With live variable analysis that should be easy to save/restore only active variables at the yield point. "Active" in the sense of "modifie

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Stefan Behnel, 23.05.2011 11:15: Vitja Makarov, 23.05.2011 10:50: 2011/5/23 Stefan Behnel: I'm fine with deallocating variables that are no longer used after the user explicitly assigned None to them (i.e. replace the None assignment by a simple "DECREF + set to NULL" in that case). I don't thi

Re: [Cython] local variable handling in generators

2011-05-23 Thread Vitja Makarov
2011/5/23 Stefan Behnel : > Vitja Makarov, 23.05.2011 10:50: >> >> 2011/5/23 Stefan Behnel: >>> >>> Vitja Makarov, 23.05.2011 10:13: With live variable analysis that should be easy to save/restore only active variables at the yield point. >>> >>> "Active" in the sense of "modified",

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Vitja Makarov, 23.05.2011 10:50: 2011/5/23 Stefan Behnel: Vitja Makarov, 23.05.2011 10:13: With live variable analysis that should be easy to save/restore only active variables at the yield point. "Active" in the sense of "modified", I suppose? That's what I was expecting. Active means tha

Re: [Cython] local variable handling in generators

2011-05-23 Thread Dag Sverre Seljebotn
On 05/23/2011 10:50 AM, Vitja Makarov wrote: 2011/5/23 Stefan Behnel: Vitja Makarov, 23.05.2011 10:13: With live variable analysis that should be easy to save/restore only active variables at the yield point. "Active" in the sense of "modified", I suppose? That's what I was expecting. Act

Re: [Cython] local variable handling in generators

2011-05-23 Thread Vitja Makarov
2011/5/23 Stefan Behnel : > Vitja Makarov, 23.05.2011 10:13: >> >> With live variable analysis that should be easy to save/restore only >> active variables at the yield point. > > "Active" in the sense of "modified", I suppose? That's what I was expecting. > Active means that variable value will b

Re: [Cython] local variable handling in generators

2011-05-23 Thread Stefan Behnel
Vitja Makarov, 23.05.2011 10:13: With live variable analysis that should be easy to save/restore only active variables at the yield point. "Active" in the sense of "modified", I suppose? That's what I was expecting. Btw now only reaching definitions analysis is implemented. I'm going to opti

Re: [Cython] local variable handling in generators

2011-05-23 Thread Vitja Makarov
2011/5/22 Stefan Behnel : > Hi, > > I've been looking at the nqueens benchmark for a while, and I think it's > actually not that a bad benchmark for generators. > > http://hg.python.org/benchmarks/file/tip/performance/bm_nqueens.py > > A better implementation only for Py2.7/Py3 is here: > > https:/