Liste des Groupes | Revenir à cl c |
On 20/06/2024 18:58, bart wrote:
During the last 20 or more years, Python implementations have gotten more and more efficient. So if there is a difference between range and xrange, there are techniques that can be used to minimise it.No, the complaint was getting it so wrong in the first place, then taking too long to fix it. (I think it was in Python 3 that you could type 'range' instead of 'xrange'.)s = 0
>
>
for i in range(10000000) :
s = s + i
print(s)
(I made it 10 million, not 1 million, because I have such a vastly faster computer than everyone else.)
$ time python2 sum.py
49999995000000
real 0m0,820s
user 0m0,632s
sys 0m0,179s
$ time python3 sum.py
49999995000000
real 0m0,868s
user 0m0,854s
sys 0m0,004s
Les messages affichés proviennent d'usenet.