Question about timeit
Thomas Rachel
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Fri Jul 22 04:08:21 EDT 2011
Am 22.07.2011 08:59 schrieb Frank Millman:
> My guess is that it is something to do with the console, but I don't
> know what. If I get time over the weekend I will try to get to the
> bottom of it.
I would guess that in the first case, python (resp. timeit.py) gets the
intended code for execution: int(float('165.0')). I. e., give the string
to float() and its result to int().
In the second case, however, timeit.py gets the string
'int(float("165.0"))' and evaluates it - which is a matter of
sub-microseconds.
The reason for this is that the Windows "shell" removes the "" in the
first case, but not the '' in the second case.
Thomas
More information about the Python-list
mailing list