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 thin

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 wrote: > On 04/12/2012 11:51 PM, Dag

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

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 had

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 w

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 Nu

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 07:24 PM, Nathaniel Smith wrote: > On Wed, Apr 11, 2012 at 10:23 PM, Travis Oliphant > 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 nu

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 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" */ >>>      void

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 Nu

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 >>

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 tak

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 ufu

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, > g

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

2012-04-10 Thread Travis Oliphant
cussion-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, > > Some of you are aware of Numba. Numb

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

2012-04-10 Thread Dag Sverre Seljebotn
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 pointers from Python to C Hi all, Some of yo

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

2012-04-10 Thread Nadav Horesh
hared 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-fun

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 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 stored as C array

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 >>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

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 > 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 wrote: >>>

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 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 >>>   wrote: On 04/10/2012 12:37 PM, Nathaniel Smith wrote: > On

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 >>wrote: >>> On 04/10/2012 12:37 PM, Nathaniel Smith wrote: On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphant wrote: >

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 > wrote: >> On 04/10/2012 12:37 PM, Nathaniel Smith wrote: >>> On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphant >>> wrote: On Apr 9, 2012, at 7:21 PM, Nathaniel Smith wrote: .

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 wrote: > On 04/10/2012 12:37 PM, Nathaniel Smith wrote: >> On Tue, Apr 10, 2012 at 1:57 AM, Travis Oliphant  wrote: >>> On Apr 9, 2012, at 7:21 PM, Nathaniel Smith wrote: >>> >>> ...isn't this an operation that will be performed once per compil

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 Oliphant 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

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 Sm

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 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 this is what is env

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 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 compared to, yo

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

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 num

[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 f