[Piglit] [PATCH 2/4] framework/log.py: Make self.__summary keys explicitly

Dylan Baker baker.dylan.c at gmail.com
Mon Feb 17 13:06:03 PST 2014


On Monday, February 17, 2014 03:48:34 PM Ilia Mirkin wrote:
> On Mon, Feb 17, 2014 at 3:39 PM, Dylan Baker <baker.dylan.c at gmail.com> 
wrote:
> > I didn't think that list comprehensions leaked, since they're supposed to
> > be usable anywhere map() and filter() is used without any additional side
> > effects. Maybe I'm wrong though.
> 
> Python 2.7.5 (default, Oct 27 2013, 05:36:27)
> [GCC 4.7.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
> >>> [x for x in xrange(10)]
> 
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> 
> >>> x
> 
> 9
> 
> >>> (y for y in xrange(10))
> 
> <generator object <genexpr> at 0x7ff5c3ddc910>
> 
> >>> y
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'y' is not defined
> 
> It's one of those warts of the language. They couldn't remove the
> leaking (until python3) because some programs had grown to implicitly
> rely on that.
> 
> Here's a fun one:
> 
> res = [(lambda: x) for x in xrange(10)]
> for r in res:
>   print r()
> 
>   -ilia

Ah yes, piglit is the only place I use python2, so I'm not aware of some of 
the nuances. That is good information to have.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140217/3a0a12b7/attachment.pgp>


More information about the Piglit mailing list