👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
Recently I started using Python3 and it"s lack of xrange
hurts.
Simple example:
Python2:
from time import time as t def count(): st = t() [x for x in xrange(10000000) if x%4 == 0] et = t() print et-st count()
Python3:
from time import time as t def xrange(x): return iter(range(x)) def count(): st = t() [x for x in xrange(10000000) if x%4 == 0] et = t() print (et-st) count()
The results are, respectively:
1.53888392448
3.215819835662842
Why is that? I mean, why xrange
has been removed? It"s such a great tool to learn. For the beginners, just like myself, like we all were at some point. Why remove it? Can somebody point me to the proper PEP, I can"t find it.
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Why is there no xrange function in Python3?, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Why is there no xrange function in Python3?
- Deutsch Why is there no xrange function in Python3?
- Français Why is there no xrange function in Python3?
- Español Why is there no xrange function in Python3?
- Türk Why is there no xrange function in Python3?
- Русский Why is there no xrange function in Python3?
- Português Why is there no xrange function in Python3?
- Polski Why is there no xrange function in Python3?
- Nederlandse Why is there no xrange function in Python3?
- 中文 Why is there no xrange function in Python3?
- 한국어 Why is there no xrange function in Python3?
- 日本語 Why is there no xrange function in Python3?
- हिन्दी Why is there no xrange function in Python3?
Texas | 2023-02-06
I was preparing for my coding interview, thanks for clarifying this - Why is there no xrange function in Python3? in Python is not the simplest one. I am just not quite sure it is the best method
Vigrinia | 2023-02-06
Maybe there are another answers? What Why is there no xrange function in Python3? exactly means?. Checked yesterday, it works!
Moscow | 2023-02-06
imp Python module is always a bit confusing 😭 Why is there no xrange function in Python3? is not the only problem I encountered. Will get back tomorrow with feedback