[Python-Dev] Tagged integers

M.-A. Lemburg mal at egenix.com
Wed Jul 14 11:16:29 CEST 2004


James Y Knight wrote:
> So I was saying to someone the other day "Gee, I wonder why Python 
> doesn't use tagged integers, it seems like it would be a lot faster than 
> allocating new objects all the time.", and they said "Cause you'd have 
> to change everything, too much work!" and I said "Nah, you only need to 
> change a few things to use macros, it'd only take a few hours, mostly 
> query-replace".
> 
> So, of course, I had to do it then, and it only took a couple hours, and 
> appears to be at least somewhat faster.
> 
> On the test that probably puts my change in the most positive light 
> possible: "x = 0;  while x < 50000000:  x = x + 1", it achieves about a 
> 50% increase in speed. More normal integer-heavy things seem to be at 
> most 20% faster.

Interesting. I would have thought that hackery like this
would result in more significant speedups. Looks like the
Python implementation is darn fast already :-)

Note that Python shares small integers and uses
a free list for the rest, so most of the times, the
implementation can create objects using already allocated
memory.

I'd rather not like to see hackery like misused pointers
in the core, so you can count me as -1 on this.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jul 14 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Python-Dev mailing list