Note that you can declare at foo_t to be a member of Bar directly, so
you don't even need to allocate it (this works if you're not getting
it as a pointer from elsehwhere). For example
cdef extern from "foo.h":
ctypedef struct foo_t:
int fd
cdef some_c_func(foo
On Thu, Jul 23, 2009 at 7:11 PM, Richard Clarke wrote:
>
> If we consider Bar to be the encapsulating class for the foo_t struct,
> in my case I need access to this foo_t struct in other classes.
That's common use case... And Cython supports that almost for free..
> Using
> Lisandro's Bar class a
On Thu, Jul 23, 2009 at 8:28 PM, Robert
Bradshaw wrote:
> On Jul 23, 2009, at 12:10 PM, Lisandro Dalcin wrote:
>
>> On Thu, Jul 23, 2009 at 10:29 AM, Richard
>> Clarke wrote:
>>> Thank you Robert, the explanation on how and where to use cdef was
>>> most helpful. I think it has just clicked(with a
On Jul 23, 2009, at 12:10 PM, Lisandro Dalcin wrote:
> On Thu, Jul 23, 2009 at 10:29 AM, Richard
> Clarke wrote:
>> Thank you Robert, the explanation on how and where to use cdef was
>> most helpful. I think it has just clicked(with a flag waving
>> 'idiot').
>>
>> The PyCObject concept is a ni
On Thu, Jul 23, 2009 at 10:29 AM, Richard Clarke wrote:
> Thank you Robert, the explanation on how and where to use cdef was
> most helpful. I think it has just clicked(with a flag waving
> 'idiot').
>
> The PyCObject concept is a nice idea, removing cdef foo_t *foo from
> outside of __init__ ? H
Thank you Robert, the explanation on how and where to use cdef was
most helpful. I think it has just clicked(with a flag waving
'idiot').
The PyCObject concept is a nice idea, removing cdef foo_t *foo from
outside of __init__ ? However, I see implications in memory
deallocation. How does cython
On Jul 23, 2009, at 3:39 AM, Richard Clarke wrote:
> Hi,
>
> Can anyone point out where I am going wrong?
Sure. There is no way convert a pointer to a Python object. (Perhaps
we could support this via http://www.python.org/doc/2.6/c-api/
cobject.html , but certainly that'll take a lot of thoug
Hi,
Can anyone point out where I am going wrong?
// foo.h
#ifndef __FOO_H__
#define __FOO_H__
typedef struct
{
int fd;
} foo_t;
foo_t* init(void);
#endif
// foo.c
#include "foo.h"
#include
foo_t* init(){
foo_t* foo = malloc(sizeof(foo_t));
return foo;
}
// foo.pyx
cdef ext