Entering a very large number
bartc
bc at freeuk.com
Sun Mar 25 08:32:39 EDT 2018
On 25/03/2018 02:47, Steven D'Aprano wrote:
> On Sun, 25 Mar 2018 00:05:56 +0100, Peter J. Holzer wrote:
>
> [...]
>>> yes, good idea
>>
>> Not if you want to avoid that string to int conversion (as you stated).
>>
>> That is still there, but in addition you now split the string into a
>> list and then join the list into a different string.
>
> I'm glad I wasn't the only one who spotted that.
>
> There's something very curious about somebody worried about efficiency
> choosing a *less* efficient solution than what they started with. To
> quote W.A. Wulf:
>
> "More computing sins are committed in the name of efficiency (without
> necessarily achieving it) than for any other single reason — including
> blind stupidity."
>
> As Donald Knuth observed:
>
> "We should forget about small efficiencies, say about 97% of the time:
> premature optimization is the root of all evil."
>
> The Original Poster (OP) is concerned about saving, what, a tenth of a
> microsecond in total? Hardly seems worth the effort, especially if you're
> going to end up with something even slower.
Using CPython on my machine, doing a string to int conversion that
specific number took 200 times as long as doing a normal assignment.
That conversion took 4 microseconds.
Not significant if it's only done once. But it might be executed a
million times.
--
bartc
More information about the Python-list
mailing list