No subject


Thu Nov 16 16:52:29 CST 2006


Ray Schumacher  writes:

> At 06:31 PM 12/15/2004 +0100, Thomas Heller wrote:
>>>   buf = (c_ulong * 2000)()
>>>   numArray[pntr:pntr+2000] = map(None, buf)
>>
>>Should work, but builds a large temporary list.  Best would be to avoid
>>temporary objects at all, like this (for memmove, you need the latest
>>ctypes release) (I assume that it is possible to get the address of a
>>numarray buffer in a similar way as is possible for a normal array
>>instance):
>
> I'm not sure it will be able to work...
> The closest thing to .buffer_info() for numarray-addressing seems to
> be info(), but it returns text:
>
>  >>> src = numarray.array(range(32), Float)
>  >>> s = info(src)
> class: <class 'numarray.numarraycore.NumArray'>
> shape: (32,)
> strides: (8,)
> byteoffset: 0
> bytestride: 8
> itemsize: 8
> aligned: 1
> contiguous: 1
> data: <memory at 00815880 with size:256 held by object 00815860 aliasing object
> 00000000>
> byteorder: little
> byteswap: 0
> type: Float64
>  >>> src._byteoffset
> 0

What a pity.  (You could try to parse the <memory at 00815880> to get the
address).

Maybe you should ask to make sure that there's no way to copy between
objects implementing the buffer protocol with some Python function that
I do not know about?

If such a function doesn't exist, ctypes' memmove function should be
changed to accept objects implementing the buffer interface.

Thomas





Secret anti-spam filter-passing text. Include with reply: 
qwertyuiop 
--=====================_131324106==.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<body>
I'm posting here to see if numarray has a method that could work like
array.buffer_info().&nbsp; numarray.info() returns a text output that
can't be used like the array method is to memmove() between ctypes and
Python arrays without parsing, apparently.<br><br>
ctypes thread with Thomas Heller below. His main question: &quot;Maybe
you should ask to make sure that there's no way to copy between<br>
objects implementing the buffer protocol with some Python function
that<br>
I do not know about?&quot;<br><br>
Cc: ctypes-users at lists.sourceforge.net<br>
Subject: Re: [ctypes-users] copying/slicing ctypes arrays, (c_ulong
*n)()<br>
In-Reply-To: &lt;5.2.0.4.2.20041215100117.0dff97b0 at blue-cove.com&gt;
(Ray<br>
&nbsp;Schumacher's message of &quot;Wed, 15 Dec 2004 10:57:45
-0800&quot;)<br>
References:
&lt;5.2.1.1.2.20041214202542.05f02920 at pop-server.san.rr.com&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;5.2.1.1.2.20041214202542.05f02920 at pop-server.san.rr.com&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;5.2.0.4.2.20041215100117.0dff97b0 at blue-cove.com&gt;<br>
Date: Wed, 15 Dec 2004 20:25:33 +0100<br>
Message-ID: &lt;is73z7ma.fsf at python.net&gt;<br><br>
MIME-Version: 1.0<br>
Content-Type: text/plain; charset=us-ascii<br>
X-UIDL: /O~!!CW8&quot;!g],&quot;!(Ec&quot;!<br>
Ray Schumacher&nbsp; writes:<br><br>
&gt; At 06:31 PM 12/15/2004 +0100, Thomas Heller wrote:<br>
&gt;&gt;&gt;&nbsp;&nbsp; buf = (c_ulong * 2000)()<br>
&gt;&gt;&gt;&nbsp;&nbsp; numArray[pntr:pntr+2000] = map(None, buf)<br>
&gt;&gt;<br>
&gt;&gt;Should work, but builds a large temporary list.&nbsp; Best would
be to avoid<br>
&gt;&gt;temporary objects at all, like this (for memmove, you need the
latest<br>
&gt;&gt;ctypes release) (I assume that it is possible to get the address
of a<br>
&gt;&gt;numarray buffer in a similar way as is possible for a normal
array<br>
&gt;&gt;instance):<br>
&gt;<br>
&gt; I'm not sure it will be able to work...<br>
&gt; The closest thing to .buffer_info() for numarray-addressing seems
to<br>
&gt; be info(), but it returns text:<br>
&gt;<br>
&gt;&nbsp; &gt;&gt;&gt; src = numarray.array(range(32), Float)<br>
&gt;&nbsp; &gt;&gt;&gt; s = info(src)<br>
&gt; class: &lt;class 'numarray.numarraycore.NumArray'&gt;<br>
&gt; shape: (32,)<br>
&gt; strides: (8,)<br>
&gt; byteoffset: 0<br>
&gt; bytestride: 8<br>
&gt; itemsize: 8<br>
&gt; aligned: 1<br>
&gt; contiguous: 1<br>
&gt; data: &lt;memory at 00815880 with size:256 held by object 00815860
aliasing object<br>
&gt; 00000000&gt;<br>
&gt; byteorder: little<br>
&gt; byteswap: 0<br>
&gt; type: Float64<br>
&gt;&nbsp; &gt;&gt;&gt; src._byteoffset<br>
&gt; 0<br><br>
What a pity.&nbsp; (You could try to parse the &lt;memory at 00815880&gt;
to get the<br>
address).<br><br>
Maybe you should ask to make sure that there's no way to copy
between<br>
objects implementing the buffer protocol with some Python function
that<br>
I do not know about?<br><br>
If such a function doesn't exist, ctypes' memmove function should 
be<br>
changed to accept objects implementing the buffer interface.<br><br>
Thomas<br><br>
<br><br>
<br>
<x-sigsep><p></x-sigsep>
Secret anti-spam filter-passing text. Include with reply: <br>
qwertyuiop</body>
</html>

--=====================_131324106==.ALT--





More information about the Numpy-discussion mailing list