High performance binary data

sturlamolden sturlamolden at yahoo.no
Fri Aug 10 11:08:31 EDT 2007


On Aug 10, 2:26 am, Steve <steve.mo... at gmail.com> wrote:
> I want to ready binary data from a udp socket effeciently as possible
> in python.  I know of the struct package but do people have any tips
> when dealing with binary data in python?  Is there a library or api
> that is faster when dealing with binary data. I am looking for a any
> one with experience or ideas on the subject.  Pointers any one?

I would recommend NumPy for manipulating binary data. It is primarily
intended for numerics, but it is excellent for dealing with any kind
of binary data as well. It can handle mutable buffers of any kind of
integer or float, as well as arrays of C-like structs (record arrays
in numpy). You can typecast and create subarrays without copying any
data, simply by providing a new "view" into the buffer. You can also
get access to strided subsections without creating copies. And it is
very fast.

www.scipy.org




More information about the Python-list mailing list