Moving towards Python 3.0 (was Re: [Python-Dev] Speed up function calls)

"Martin v. Löwis" martin at v.loewis.de
Mon Jan 31 20:21:10 CET 2005


Evan Jones wrote:
> The next page has a 
> micro-benchmark that shows reference counting performing very poorly. 
> Not to mention that Python has a garbage collector *anyway,* so wouldn't 
> it make sense to get rid of the reference counting?

It's not clear what these numbers exactly mean, but I don't believe
them. With the Python GIL, the increments/decrements don't have to
be atomic, which already helps in a multiprocessor system (as you
don't need a buslock). The actual costs of GC occur when a
collection happens - and it should always be possible to construct
cases where the collection needs longer, because it has to look
at so much memory.

I like reference counting because of its predictability. I
deliberately do

data = open(filename).read()

without having to worry about closing the file - just because
reference counting does it for me. I guess a lot of code will
break when you drop refcounting - perhaps unless an fopen
failure will trigger a GC.

Regards,
Martin


More information about the Python-Dev mailing list