[Python-Dev] int(string)
Adam Olsen
rhamph at gmail.com
Sat Oct 22 18:49:38 CEST 2005
> Tim Peters <tim.peters at gmail.com> writes:
>
> > Turns out it's _not_ input speed that's the problem here, and not even
> > mainly the speed of integer mod: the bulk of the time is spent in
> > int(string) (and, yes, that's also far more important to the problem
> > Neal was looking at than list.append time). If you can even track all
> > the levels of C function calls that ends up invoking <wink>, you find
> > yourself in PyOS_strtoul(), which is a nifty all-purpose routine that
> > accepts inputs in bases 2 thru 36, can auto-detect base, and does
> > platform-independent overflow checking at the cost of a division per
> > digit. All those are features, but it makes for sloooow conversion.
>
> > I assume it's the overflow-checking that's the major time sink,
Are you sure?
https://sourceforge.net/tracker/index.php?func=detail&aid=1334979&group_id=5470&atid=305470
That patch removes the division from the loop (and fixes the bugs),
but gives only a small increase in speed.
--
Adam Olsen, aka Rhamphoryncus
More information about the Python-Dev
mailing list