[Numpy-discussion] unpacking data values into array of bits

Nathaniel Smith njs at pobox.com
Thu Feb 12 12:15:31 EST 2015


On 12 Feb 2015 07:55, "R Schumacher" <rays at blue-cove.com> wrote:
>
>  >>> s='np.unpackbits(np.frombuffer(np.asarray(np.pi),
> dtype=np.uint8)).astype(np.int32)'
>  >>> timr(s)
> 0.000252470827292

I'm not sure what timr is, but you should check out ipython and its built
in %timeit command, which is trivial to use but, because it uses the
'timeit' module, goes to extreme effort to get accurate times (minimizing
timing overhead, performing multiple runs, etc.).

-n
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150212/72079da3/attachment.html>


More information about the NumPy-Discussion mailing list