Pyhon 2.x or 3.x, which is faster?
Mark Lawrence
breamoreboy at yahoo.co.uk
Fri Mar 11 17:35:41 EST 2016
On 11/03/2016 22:24, BartC wrote:
> On 11/03/2016 21:59, Mark Lawrence wrote:
>> On 11/03/2016 18:57, BartC wrote:
>
>> def test():
>> s=""
>> for i in range(10000000):
>> s+="*"
>> print (len(s))
>>
>> test()
>
>> The minor snag that you might like to correct with your microbenchmark,
>> which any experienced Python programmer knows, is that you *NEVER, EVER*
>> create strings like this.
>
> Why not? Chris said his version runs much faster (even allowing for
> different machines), and might have a special optimisation for it.
>
> And I think it can be optimised if, for example, there are no other
> references to the string that s refers to.
>
> So what's wrong with trying to fix it rather that using a workaround?
>
The mere fact that you have to ask indicates quite clearly that you know
nothing about Python. I'm not going to spoon feed you, go and do your
own research.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list