[Python-Dev] int(string)

Alan McIntyre alan.mcintyre at esrgtech.com
Mon Oct 24 07:43:26 CEST 2005


Tim Peters wrote:

>[Adam Olsen]
>
>>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.
>>
>In any case, I agree it _should_ fix the bugs (although it also needs
>new tests to verify that).
>
I started with Adam's patch and did some additional work on
PyOS_strtoul.  I ended up with a patch that seems to correctly evaluate
the tests that Tim listed in bug #1334662, includes new tests (in
test_builtin), passes (almost) all of "make test," and it seems to be
somewhat faster (~20%) for a "spoj.sphere.pl"-like test on a ~8MB input
file.  All the ugly details are here (along with my ugly code):

http://sourceforge.net/tracker/index.php?func=detail&aid=1335972&group_id=5470&atid=305470

When running "make test" I get some errors in test_array and
test_compile that did not occur in the build from CVS.  Given the inputs
to long() have '.' characters in them, I assume that these tests really
should be failing as implemented, but I haven't dug into them to see
what's going on:

======================================================================
ERROR: test_repr (__main__.FloatTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_array.py", line 187, in test_repr
    self.assertEqual(a, eval(repr(a), {"array": array.array}))
ValueError: invalid literal for long(): 10000000000.0
 
======================================================================
ERROR: test_repr (__main__.DoubleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_array.py", line 187, in test_repr
    self.assertEqual(a, eval(repr(a), {"array": array.array}))
ValueError: invalid literal for long(): 10000000000.0
 
----------------------------------------------------------------------

test test_compile crashed -- exceptions.ValueError: invalid literal for
long():
90000000000000.



More information about the Python-Dev mailing list