No subject


Thu Nov 16 16:51:17 EST 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().  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: "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>
Cc: ctypes-users at lists.sourceforge.net<br>
Subject: Re: [ctypes-users] copying/slicing ctypes arrays, (c_ulong
*n)()<br>
In-Reply-To: <5.2.0.4.2.20041215100117.0dff97b0 at blue-cove.com>
(Ray<br>
 Schumacher's message of "Wed, 15 Dec 2004 10:57:45
-0800")<br>
References:
<5.2.1.1.2.20041214202542.05f02920 at pop-server.san.rr.com><br>
<x-tab>        </x-tab><5.2.1.1.2.20041214202542.05f02920 at pop-server.san.rr.com><br>
<x-tab>        </x-tab><5.2.0.4.2.20041215100117.0dff97b0 at blue-cove.com><br>
Date: Wed, 15 Dec 2004 20:25:33 +0100<br>
Message-ID: <is73z7ma.fsf at python.net><br><br>
MIME-Version: 1.0<br>
Content-Type: text/plain; charset=us-ascii<br>
X-UIDL: /O~!!CW8"!g],"!(Ec"!<br>
Ray Schumacher  writes:<br><br>
> At 06:31 PM 12/15/2004 +0100, Thomas Heller wrote:<br>
>>>   buf = (c_ulong * 2000)()<br>
>>>   numArray[pntr:pntr+2000] = map(None, buf)<br>
>><br>
>>Should work, but builds a large temporary list.  Best would
be to avoid<br>
>>temporary objects at all, like this (for memmove, you need the
latest<br>
>>ctypes release) (I assume that it is possible to get the address
of a<br>
>>numarray buffer in a similar way as is possible for a normal
array<br>
>>instance):<br>
><br>
> I'm not sure it will be able to work...<br>
> The closest thing to .buffer_info() for numarray-addressing seems
to<br>
> be info(), but it returns text:<br>
><br>
>  >>> src = numarray.array(range(32), Float)<br>
>  >>> s = info(src)<br>
> class: <class 'numarray.numarraycore.NumArray'><br>
> shape: (32,)<br>
> strides: (8,)<br>
> byteoffset: 0<br>
> bytestride: 8<br>
> itemsize: 8<br>
> aligned: 1<br>
> contiguous: 1<br>
> data: <memory at 00815880 with size:256 held by object 00815860
aliasing object<br>
> 00000000><br>
> byteorder: little<br>
> byteswap: 0<br>
> type: Float64<br>
>  >>> src._byteoffset<br>
> 0<br><br>
What a pity.  (You could try to parse the <memory at 00815880>
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