On Wed, Mar 25, 2015 at 3:46 PM, <kai.pet...@gmail.com> wrote: > Now I have just read the latest spec and speed/memory may become issues: > > 1 bit images of a size of 1024 x 1280 need to be processed this way, so > 1310720 list elements. Also needs to be 2.7 only. > > Any recommendations?
2.7 only? Then my solution won't work (I just tried to port it, and integers don't have to_bytes). Paul's solution works. Here's an alternative: >>> import numpy >>> list(numpy.packbits(numpy.array(l),-1)) [177, 105, 117] Of course, this does mean installing numpy. It is crushing the nut with the triphammer - an absurd extravagance of energy, but the nut is effectively crushed all the same. ChrisA -- https://mail.python.org/mailman/listinfo/python-list