[Python-Dev] set/dict comprehensions don't leak in Py2.7 - intentional? (original) (raw)
Tim Golden mail at timgolden.me.uk
Mon Jul 5 15:12:15 CEST 2010
- Previous message: [Python-Dev] set/dict comprehensions don't leak in Py2.7 - intentional?
- Next message: [Python-Dev] set/dict comprehensions don't leak in Py2.7 - intentional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 05/07/2010 14:06, Stefan Behnel wrote:
Hi,
I only noticed now that set/dict comprehensions were backported to 2.7 without letting the loop Variables leak into the surrounding scope. So they now behave different from list comprehensions. Is this intentional or just a backporting oversight? I'm asking because we had a discussion about the 'right' semantics several times on the Cython list, and the current behaviour is that all comprehensions leak when compiling Py2 code and the do not leak when compiling Py3 code. I would hate to fix that up to match 2.7 and then see that the behaviour in Py2.7 is to be considered an accident.
Depends on your definition of "comprehension", but generator expressions have always not leaked, so these are already different in Py2.x:
[i for i in range (10)]
list (i for i in range (10))
I had understood (without being able to put my finger on a relevant thread) that all comprehensions were going not leak their loop variables in the future.
TJG
- Previous message: [Python-Dev] set/dict comprehensions don't leak in Py2.7 - intentional?
- Next message: [Python-Dev] set/dict comprehensions don't leak in Py2.7 - intentional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]