[Pyrex] first post, ref count problem

leonardo leonmaf at yahoo.com
Wed Jan 31 23:54:38 UTC 2007


Greg Ewing:
> The simplest and safest way to deal with this is to
> make your tyitem an extension type rather than a
> struct:
>    cdef class tyitem:
>      cdef object pl
>      cdef object pitem
>      cdef object pr

Thank you for your suggestions. I know Python and I
have built linked structures with C, Pascal, etc, but
I have no idea how to change my Chain code to use such
pl/pr "pointer" objects inside that Item object.
I have tried to change it anyway, I have had to
rewrite lot of the code:
http://rafb.net/p/KD8r0394.html

Before Chain used 5.42 seconds to append 1000000
items, using about 37.2 MB (a CPython dynamic array
(list) needs about 2.5 seconds to do the same thing).
Now Chain needs 17.5 seconds to append them, using
53.7 MB, and at the end the final del doesn't free the
memory anyway, that's really too much, it's slower
than Psyco. My code is probably silly, it looks like
Python now, can you suggest how to improve it? (The
purpose of this class is for speed and time
efficiency, othwerwise it's time to switch to another
compiled language, like ObjectPascal or D and stop
fighting against Python.)


> I'd be checking the generated C
> code to make sure they weren't introducing any
> extra increfs or decrefs.

The produced code (of the original version) is a long
jungle, it contains LOTS of increfs or decrefs, I
don't think I am able to sort it out, my fault.


> BTW, your loop for freeing the list elements looks
> more complicated than it needs to be.

Maybe this is a too much early speed optimization of
mine. My version needs just 1 assignament for every
Item, inside the loop, yours 2.

later,
leonardo


 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/



More information about the Pyrex mailing list