map() in Python 3 is a lazy generator, meaning it has no length. In Python 2, map() produced a list which does possess a length.
Without this change, the example in the README.rst fails on OSX/XQuartz Python 3.6 installation.
This PR casts the map() generator to a list.
Proof that this is of negligible penalty:
(cpython36) benjolitz-laptop:~/software/PyVirtualDisplay [master]$ python -m timeit -s 'item = []' 'item = list(item)'
10000000 loops, best of 3: 0.182 usec per loop
I don't think anyone will cry about losing 0.182 microseconds. They might cry about pyvirtualdisplay throwing a TypeError: object of type 'map' has no len()
Coverage remained the same at 84.722% when pulling 23343af4a857223f3d1da11d00d14ae6061eb4dd on benjolitz:master into da6544e4bd8974cb3af9a61538ebcd17344bce30 on ponty:master.
map()
in Python 3 is a lazy generator, meaning it has no length. In Python 2,map()
produced alist
which does possess a length.Without this change, the example in the README.rst fails on OSX/XQuartz Python 3.6 installation.
This PR casts the
map()
generator to a list.Proof that this is of negligible penalty:
I don't think anyone will cry about losing 0.182 microseconds. They might cry about pyvirtualdisplay throwing a
TypeError: object of type 'map' has no len()