Re: Strange array.array performance

2009-03-11 Thread Aahz
In article , Maxim Khitrov wrote: > >Interesting, though I'm not able to replicate that last outcome. The >string method is still the fastest on my machine. Furthermore, it >looks like the order in which you do the multiplication also matters - >(8 * size * '\0') is faster than ('\0' * 8 * size).

Re: Strange array.array performance

2009-02-20 Thread Maxim Khitrov
On Fri, Feb 20, 2009 at 2:42 AM, Scott David Daniels wrote: > Maxim Khitrov wrote: >> >> ... Here's the function that I'll be using from now on. It gives me >> exactly the behavior I need, with an int initializer being treated as >> array size. Still not as efficient as it could be if supported >>

Re: Strange array.array performance

2009-02-19 Thread Scott David Daniels
Maxim Khitrov wrote: ... Here's the function that I'll be using from now on. It gives me exactly the behavior I need, with an int initializer being treated as array size. Still not as efficient as it could be if supported natively by array (one malloc instead of two + memmove + extra function cal

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 10:06 PM, David Cournapeau wrote: > On Fri, Feb 20, 2009 at 11:43 AM, Maxim Khitrov wrote: >> >> Yes, I may have a case where one thread is still sending data, while >> another tries to close the connection, or two threads trying to close >> the connection at the same time

Re: Strange array.array performance

2009-02-19 Thread David Cournapeau
On Fri, Feb 20, 2009 at 11:43 AM, Maxim Khitrov wrote: > > Yes, I may have a case where one thread is still sending data, while > another tries to close the connection, or two threads trying to close > the connection at the same time. In both cases, I need some parts of > the code to be atomic to

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 9:15 PM, John Machin wrote: > On Feb 20, 6:53 am, Maxim Khitrov wrote: >> On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern wrote: >> > On 2009-02-19 12:52, Maxim Khitrov wrote: >> >> >> Hello all, >> >> >> I'm currently writing a Python<-> MATLAB interface with ctypes and >>

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 9:34 PM, David Cournapeau wrote: > On Fri, Feb 20, 2009 at 4:53 AM, Maxim Khitrov wrote: >> On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern wrote: >>> On 2009-02-19 12:52, Maxim Khitrov wrote: Hello all, I'm currently writing a Python<-> MATLAB interface

Re: Strange array.array performance

2009-02-19 Thread David Cournapeau
On Fri, Feb 20, 2009 at 4:53 AM, Maxim Khitrov wrote: > On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern wrote: >> On 2009-02-19 12:52, Maxim Khitrov wrote: >>> >>> Hello all, >>> >>> I'm currently writing a Python<-> MATLAB interface with ctypes and >>> array.array class, using which I'll need to p

Re: Strange array.array performance

2009-02-19 Thread John Machin
On Feb 20, 6:53 am, Maxim Khitrov wrote: > On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern wrote: > > On 2009-02-19 12:52, Maxim Khitrov wrote: > > >> Hello all, > > >> I'm currently writing a Python<->  MATLAB interface with ctypes and > >> array.array class, using which I'll need to push large amo

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 7:01 PM, Scott David Daniels wrote: > Maxim Khitrov wrote: >> >> On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern >> wrote: >> I have, but numpy is not currently available for python 2.6, which is >> what I need for some other features, and I'm trying to keep the >> dependenci

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 7:01 PM, Scott David Daniels wrote: > Maxim Khitrov wrote: >> >> On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern >> wrote: >> I have, but numpy is not currently available for python 2.6, which is >> what I need for some other features, and I'm trying to keep the >> dependenci

Re: Strange array.array performance

2009-02-19 Thread Scott David Daniels
Maxim Khitrov wrote: On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern wrote: I have, but numpy is not currently available for python 2.6, which is what I need for some other features, and I'm trying to keep the dependencies down in any case The only feature that I'm missing with array.array is t

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 2:23 PM, Gabriel Genellina wrote: > En Thu, 19 Feb 2009 16:52:54 -0200, Maxim Khitrov > escribió: > >> input = array('B', range(256) * 1) >> >> # Case 1 >> start = clock() >> data1 = array('B', input) >> print format(clock() - start, '.10f') > >> That seems very wrong.

Re: Strange array.array performance

2009-02-19 Thread Maxim Khitrov
On Thu, Feb 19, 2009 at 2:35 PM, Robert Kern wrote: > On 2009-02-19 12:52, Maxim Khitrov wrote: >> >> Hello all, >> >> I'm currently writing a Python<-> MATLAB interface with ctypes and >> array.array class, using which I'll need to push large amounts of data >> to MATLAB. > > Have you taken a lo

Re: Strange array.array performance

2009-02-19 Thread Robert Kern
On 2009-02-19 12:52, Maxim Khitrov wrote: Hello all, I'm currently writing a Python<-> MATLAB interface with ctypes and array.array class, using which I'll need to push large amounts of data to MATLAB. Have you taken a look at mlabwrap? http://mlabwrap.sourceforge.net/ At the very least,

Re: Strange array.array performance

2009-02-19 Thread Gabriel Genellina
En Thu, 19 Feb 2009 16:52:54 -0200, Maxim Khitrov escribió: input = array('B', range(256) * 1) # Case 1 start = clock() data1 = array('B', input) print format(clock() - start, '.10f') That seems very wrong. In the end, all arrays have the same data, but by specifying it in the constru