News for hackers. Stuff that matters.
Re:Pycraft: Minecraft engine in Python by rnhmjoj on Tuesday April 19, 2016 @02:15AM (#11525187)
In python 3 range() does not build a list but produce a range object. Testing x in range(a,b) will actually call the __contains__ method of the object which is O(1). The only overhead here may be the object creation. See this http://stackoverflow.com/q/30081275
Re:Pycraft: Minecraft engine in Python by daveguy on Tuesday April 19, 2016 @08:07AM (#11526356)
It may be O(1), but the constant of a __contains__ method is almost certainly much higher than the constant of an if 1 <= len(vals) <= 5: statement.