--
http://mail.python.org/mailman/listinfo/python-list
Hrvoje Niksic xemacs.org> writes:
...
> > You are getting that error because Carl forgot to cast the descriptor
> > to the appropriate C type, in this case PyMemberDescrObject. The last
> > line is also incorrect, I think. Try something like this:
...
The code you gave was great, thanks! Now we
On Sep 12, 10:01 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> Chris <[EMAIL PROTECTED]> writes:
> >> descr = GetAttrString(cls,"varname");
> >> offset = descr->d_member->offset;
> >> slotvar = (PyObject*)(((char*)obj)+offset)
>
> > Unfortunately, I am inexperienced at this kind of thing, so I was
Hrvoje Niksic <[EMAIL PROTECTED]> writes:
> Chris <[EMAIL PROTECTED]> writes:
>
>>> descr = GetAttrString(cls,"varname");
>>> offset = descr->d_member->offset;
>>> slotvar = (PyObject*)(((char*)obj)+offset)
>>
>> Unfortunately, I am inexperienced at this kind of thing, so I wasn't
>> able to get s
Chris <[EMAIL PROTECTED]> writes:
>> descr = GetAttrString(cls,"varname");
>> offset = descr->d_member->offset;
>> slotvar = (PyObject*)(((char*)obj)+offset)
>
> Unfortunately, I am inexperienced at this kind of thing, so I wasn't
> able to get something working. Maybe someone could tell me what's
Chris <[EMAIL PROTECTED]> writes:
>> In my experience, as long as you're
>> accessing simple slots, you should notice a difference.
>
> (I'm not sure what you mean by a 'simple slot'.
I mean a slot defined by __slots__ = slot1, slot2, slot3, ..., without
descriptors or specific __getattribute__ c
Hrvoje Niksic xemacs.org> writes:
...
> Chris users.sourceforge.net> writes:
>
> >> PyObject_GetAttrString is convenient, but it creates a Python string
> >> only so it can intern it (and in most cases throw away the freshly
> >> created version). For maximum efficiency, pre-create the string
>
Carl Banks gmail.com> writes:
...
> You can determine the offset the of the slot in the object structure
> by
> querying the member descriptor of the type object.
That sounds like just the kind of thing we were looking for - thanks!
> descr = GetAttrString(cls,"varname");
> offset = descr->d_mem
Chris <[EMAIL PROTECTED]> writes:
>> PyObject_GetAttrString is convenient, but it creates a Python string
>> only so it can intern it (and in most cases throw away the freshly
>> created version). For maximum efficiency, pre-create the string
>> object using PyString_InternFromString, and use tha
Chris wrote:
Ok, thanks for the confirmation. We'd been hoping to avoid creating
such a struct...
Don't worry, a C extension with its own struct isn't hard to write. Your
C code can access the member variables w/o using any Python API. You'll
get the full speed of C. :]
Christian
--
http:/
On Sep 10, 7:41 am, Chris <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'd like to be able to access an attribute of a particular Python
> object as fast as possible from some C code.
>
> I wondered if using __slots__ to store the attribute would allow me to
> do this in a faster way.
>
> The reason I'd li
Hrvoje Niksic xemacs.org> writes:
...
> [ You can use the capi-sig for questions like this; see
> http://mail.python.org/mailman/listinfo/capi-sig ]
Thanks, I had no idea about that.
> PyObject_GetAttrString is convenient, but it creates a Python string
> only so it can intern it (and in most
Christian Heimes cheimes.de> writes:
...
> You can use slots to increase the performance but it doesn't work
> like you think. If you need it *really* fast than write a C
> Extension, store the data in a C struct and access the data via
> PyMemberDef.
Ok, thanks for the confirmation. We'd been ho
[ You can use the capi-sig for questions like this; see
http://mail.python.org/mailman/listinfo/capi-sig ]
Chris <[EMAIL PROTECTED]> writes:
> I'd like to be able to access an attribute of a particular Python
> object as fast as possible from some C code.
>
> I wondered if using __slots__ to sto
Chris wrote:
Hi,
I'd like to be able to access an attribute of a particular Python
object as fast as possible from some C code.
I wondered if using __slots__ to store the attribute would allow me to
do this in a faster way.
The reason I'd like to do this is because I need to access the
attribu
15 matches
Mail list logo