[Pyrex] Creating a Non-GC type

John Arbash Meinel john at arbash-meinel.com
Fri Oct 2 04:18:53 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've been working on creating a tuple-like object that is limited in its
references, so that it does not have to participate in the python
Garbage Collector. (Currently it only references strings or other tuples
that reference strings.)[1]

I can create it fairly easily in C (and have a pretty good version), but
I'd rather be doing it in Pyrex. I keep running into boilerplate code
that Pyrex would take care of for me.

However, I haven't found any way to tell pyrex not to set the "HAVE_GC"
flag. From what I can tell, the code says "if you have any attributes,
then you must HAVE_GC".

Anyway, maybe the answer is just "that isn't supported", and I'll live
with that. I have it all done in C, I was just hoping to ease the future
maintenance burden and move into pyrex.

John
=:->



[1] The 2 main reasons are
  a) Memory. A empty tuple takes 12-bytes on 32-bit + 12-16 bytes of GC
     header overhead. (12 for py2.5, 16 for py2.6.) When you have 400k
     entries made up of 3 tuples you can save ~18MB of memory.
  b) Speed. Walking all of these objects during GC is wasteful, given
     that none of them can participate in a reference cycle. In some
     semi-artificial tests reading in the data structures, I've seen a
     2:1 speedup.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrFYw0ACgkQJdeBCYSNAANdswCdHthrTCUrFQvyfoph72Ct+D/s
X98AoIuoKHqBWbsFn9EIgLWQioI3q7sv
=YlJg
-----END PGP SIGNATURE-----



More information about the Pyrex mailing list