[Numpy-discussion] fast constructor for arrays from byte data (unpickling?)

Paul F. Dubois paul at pfdubois.com
Tue Aug 7 15:56:02 EDT 2001


See fromstring() 
>>> import Numeric
>>> x=Numeric.arange(10)
>>> s=x.tostring()
>>> y = Numeric.fromstring(s)
>>> y
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> 

-----Original Message-----
From: numpy-discussion-admin at lists.sourceforge.net
[mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Hung
Jung Lu
Sent: Tuesday, August 07, 2001 12:50 PM
To: numpy-discussion at lists.sourceforge.net
Subject: [Numpy-discussion] fast constructor for arrays from byte data
(unpickling?)


Hi,

Arrays have a method called tostring() which generates
the binary data. Is there an inverse function to that?
That is, generating an array from the binary data
string?

For large matrices, pickling/unpickling is a bit too
much overhead (data stored as ASCII character strings
instead of binary data strings.) I know, I am talking
about a factor 4 here. But there is a big difference
between 1 minute loading time and 4 minute loading
time.

I would imagine this is a very common problem/request
for people working with large matrices. And I am sure
hacking the C code to provide another fast constructor
for arrays from binary strings won't be too hard. The
questions is: has anyone already tried it? Is it
already there?

(For the kludge masters: one kludge is of course to
store the binary data on disk, then use cStringIO to
build the pickled file and then unpickle from the
cStringIO. Speed is probably OK since the pickled file
lives on RAM. But that's a kludge. :) )

regards,

Hung Jung


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/numpy-discussion





More information about the NumPy-Discussion mailing list