Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-19 Thread Dag Sverre Seljebotn
On 04/12/2012 11:51 PM, Dag Sverre Seljebotn wrote: On 04/12/2012 11:13 PM, Travis Oliphant wrote: Dag, Thanks for the link to your CEP. This is the first time I've seen it. You probably referenced it before, but I hadn't seen it. That CEP seems along the lines of what I was thinking

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-19 Thread Travis Oliphant
Thanks for the status update. A couple of weeks is a fine timeline to wait. Are you envisioning that the ufuncs in NumPy would have the nativecall attribute? -- Travis Oliphant (on a mobile) 512-826-7480 On Apr 19, 2012, at 6:00 AM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote:

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-19 Thread Dag Sverre Seljebotn
On 04/19/2012 04:17 PM, Travis Oliphant wrote: Thanks for the status update. A couple of weeks is a fine timeline to wait. Are you envisioning that the ufuncs in NumPy would have the nativecall attribute? I'm envisioning that they would be able to support CEP 1000, yes, but I don't think

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Nadav Horesh
Example: lib = ctypes.CDLL('libm.dylib') address_as_integer = ctypes.cast(lib.sin, ctypes.c_void_p).value Excellent! Sorry for the hijack, thanks for rhe ride, Nadav. ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Nathaniel Smith
On Wed, Apr 11, 2012 at 10:23 PM, Travis Oliphant teoliph...@gmail.com wrote: In the mean-time, I think we could do as Robert essentially suggested and just use Capsule Objects around an agreed-upon simple C-structure:      int   id   /* Some number that can be used as a type-check */      

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Dag Sverre Seljebotn
On 04/12/2012 07:24 PM, Nathaniel Smith wrote: On Wed, Apr 11, 2012 at 10:23 PM, Travis Oliphantteoliph...@gmail.com wrote: In the mean-time, I think we could do as Robert essentially suggested and just use Capsule Objects around an agreed-upon simple C-structure: int id /* Some

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Travis Oliphant
Dag, Thanks for the link to your CEP. This is the first time I've seen it. You probably referenced it before, but I hadn't seen it. That CEP seems along the lines of what I was thinking of.We can make scipy follow that CEP and NumPy as well in places that it needs function pointers.

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Dag Sverre Seljebotn
On 04/12/2012 11:13 PM, Travis Oliphant wrote: Dag, Thanks for the link to your CEP. This is the first time I've seen it. You probably referenced it before, but I hadn't seen it. That CEP seems along the lines of what I was thinking of.We can make scipy follow that CEP and NumPy as

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Travis Oliphant
On Apr 12, 2012, at 4:51 PM, Dag Sverre Seljebotn wrote: On 04/12/2012 11:13 PM, Travis Oliphant wrote: Dag, Thanks for the link to your CEP. This is the first time I've seen it. You probably referenced it before, but I hadn't seen it. That CEP seems along the lines of what I was

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-12 Thread Dag Sverre Seljebotn
On 04/12/2012 11:55 PM, Travis Oliphant wrote: On Apr 12, 2012, at 4:51 PM, Dag Sverre Seljebotn wrote: On 04/12/2012 11:13 PM, Travis Oliphant wrote: Dag, Thanks for the link to your CEP. This is the first time I've seen it. You probably referenced it before, but I hadn't seen it.

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Dag Sverre Seljebotn
On 04/10/2012 02:11 AM, Travis Oliphant wrote: Hi all, Some of you are aware of Numba. Numba allows you to create the equivalent of C-function's dynamically from Python. One purpose of this system is to allow NumPy to take these functions and use them in operations like ufuncs,

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Travis Oliphant
On 04/10/2012 02:11 AM, Travis Oliphant wrote: Hi all, Some of you are aware of Numba. Numba allows you to create the equivalent of C-function's dynamically from Python. One purpose of this system is to allow NumPy to take these functions and use them in operations like ufuncs,

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Dag Sverre Seljebotn
On 04/11/2012 11:00 PM, Travis Oliphant wrote: On 04/10/2012 02:11 AM, Travis Oliphant wrote: Hi all, Some of you are aware of Numba. Numba allows you to create the equivalent of C-function's dynamically from Python. One purpose of this system is to allow NumPy to take these functions

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-11 Thread Travis Oliphant
Thoughts? I really hope we can find some project-neutral common ground, so that lots of tools (Cython, f2py, numba, C extensions in NumPy and SciPy) can agree on how to unbox callables. A new extension type in NumPy would not fit this bill I feel. I've created a specification for

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Nathaniel Smith
On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphant tra...@continuum.io wrote: On Apr 9, 2012, at 7:21 PM, Nathaniel Smith wrote: ...isn't this an operation that will be performed once per compiled function? Is the overhead of the easy, robust method (calling ctypes.cast) actually measurable as

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Robert Kern
On Tue, Apr 10, 2012 at 01:11, Travis Oliphant teoliph...@gmail.com wrote:        1) Create an API for such Ctypes function pointers in NumPy and use the ctypes object structure.  If ctypes were to ever change it's object structure we would have to adapt this API.        Something like

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
Hi Travis, we've been discussing almost the exact same thing in Cython (on a workshop, not on the mailing list, I'm afraid). Our specific example-usecase was passing a Cython function to scipy.integrate. On 04/10/2012 02:57 AM, Travis Oliphant wrote: On Apr 9, 2012, at 7:21 PM, Nathaniel

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
On 04/10/2012 12:37 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphanttra...@continuum.io wrote: On Apr 9, 2012, at 7:21 PM, Nathaniel Smith wrote: ...isn't this an operation that will be performed once per compiled function? Is the overhead of the easy, robust

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Nathaniel Smith
On Tue, Apr 10, 2012 at 1:39 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 12:37 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphanttra...@continuum.io  wrote: On Apr 9, 2012, at 7:21 PM, Nathaniel Smith wrote: ...isn't this an operation that

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
On 04/10/2012 03:00 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:39 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 12:37 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphanttra...@continuum.io wrote: On Apr 9, 2012, at 7:21 PM,

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
On 04/10/2012 03:10 PM, Dag Sverre Seljebotn wrote: On 04/10/2012 03:00 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:39 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 12:37 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:57 AM, Travis

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Nathaniel Smith
On Tue, Apr 10, 2012 at 2:15 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 03:10 PM, Dag Sverre Seljebotn wrote: On 04/10/2012 03:00 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:39 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no   wrote: On 04/10/2012

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
On 04/10/2012 03:29 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 2:15 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 03:10 PM, Dag Sverre Seljebotn wrote: On 04/10/2012 03:00 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:39 PM, Dag Sverre Seljebotn

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
On 04/10/2012 03:38 PM, Dag Sverre Seljebotn wrote: On 04/10/2012 03:29 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 2:15 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 03:10 PM, Dag Sverre Seljebotn wrote: On 04/10/2012 03:00 PM, Nathaniel Smith wrote: On

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Nathaniel Smith
On Tue, Apr 10, 2012 at 2:38 PM, Dag Sverre Seljebotn d.s.seljeb...@astro.uio.no wrote: On 04/10/2012 03:29 PM, Nathaniel Smith wrote: Right, that's what I wasn't getting until you mentioned strcmp :-). That said, the core numpy dtypes are singletons. For this purpose, the signature could be

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Nadav Horesh
library? Nadav. From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] On Behalf Of Travis Oliphant [teoliph...@gmail.com] Sent: 10 April 2012 03:11 To: Discussion of Numerical Python Subject: [Numpy-discussion] Getting C-function

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Dag Sverre Seljebotn
. _ From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] On Behalf Of Travis Oliphant [teoliph...@gmail.com] Sent: 10 April 2012 03:11 To: Discussion of Numerical Python Subject: [Numpy-discussion] Getting C-function pointers from Python to C Hi all

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-10 Thread Travis Oliphant
To: Discussion of Numerical Python Subject: [Numpy-discussion] Getting C-function pointers from Python to C Hi all, Some of you are aware of Numba. Numba allows you to create the equivalent of C-function's dynamically from Python. One purpose of this system is to allow NumPy to take

[Numpy-discussion] Getting C-function pointers from Python to C

2012-04-09 Thread Travis Oliphant
Hi all, Some of you are aware of Numba. Numba allows you to create the equivalent of C-function's dynamically from Python. One purpose of this system is to allow NumPy to take these functions and use them in operations like ufuncs, generalized ufuncs, file-reading, fancy-indexing, and so

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-09 Thread Nathaniel Smith
...isn't this an operation that will be performed once per compiled function? Is the overhead of the easy, robust method (calling ctypes.cast) actually measurable as compared to, you know, running an optimizing compiler? I mean, I doubt there'd be any real problem with adding this extra API to

Re: [Numpy-discussion] Getting C-function pointers from Python to C

2012-04-09 Thread Travis Oliphant
On Apr 9, 2012, at 7:21 PM, Nathaniel Smith wrote: ...isn't this an operation that will be performed once per compiled function? Is the overhead of the easy, robust method (calling ctypes.cast) actually measurable as compared to, you know, running an optimizing compiler? Yes, there can