Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > High performance binary data

Reply
Thread Tools

High performance binary data

 
 
Steve
Guest
Posts: n/a
 
      08-10-2007
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?

Thanks
Steve

 
Reply With Quote
 
 
 
 
Marc 'BlackJack' Rintsch
Guest
Posts: n/a
 
      08-10-2007
On Fri, 10 Aug 2007 00:26:54 +0000, Steve 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 don't know if it is faster, but maybe constructing objects with
the `ctypes` module let you write more readable code as you can treat and
access C ``struct``\s like objects.

For the "fast" part of the question you might consider actually measuring
your program, as the task may be I/O bound i.e. Python may be faster than
the data comes in regardless of which module, `struct` or `ctypes`, you
use to tear apart and access the data.

Ciao,
Marc 'BlackJack' Rintsch
 
Reply With Quote
 
 
 
 
Nick Craig-Wood
Guest
Posts: n/a
 
      08-10-2007
Steve <(E-Mail Removed)> 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?


Check out construct: http://construct.wikispaces.com/

--
Nick Craig-Wood <(E-Mail Removed)> -- http://www.craig-wood.com/nick
 
Reply With Quote
 
sturlamolden
Guest
Posts: n/a
 
      08-10-2007
On Aug 10, 2:26 am, Steve <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
High Def Brings High Sales Hopes. Allan DVD Video 59 08-08-2005 06:03 PM
What to do if you've made a new high performance data structure? Theodore H. Smith C Programming 4 04-21-2004 05:16 PM
Looking for high-end 18- or 19-inch flat panels with high resolution. KL234 Digital Photography 6 02-26-2004 08:18 PM
USB High Speed against USB Non High Speed DannyD1355 Computer Support 1 09-07-2003 02:59 AM



Advertisments