May-17-2019, 07:13 PM
no, it is not necessary to create a sequence to determine len(). the object can implement the .__len__() method to achieve that. i could create a subclass of these various network objects and include that method. but it is easy enough to determine the length from the network prefix length that i would not bother to make such subclasses for this purpose.
the new range class can do this, up to a point. apparently, it is implemented in C, in which numbers 2**64 and up require more code (BTDT in C).
the new range class can do this, up to a point. apparently, it is implemented in C, in which numbers 2**64 and up require more code (BTDT in C).
Output:>>> len(range(6,2**60,3))
384307168202282324
>>> len(range(6,2**66,3))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t
do you think it created a 341 petabyte sequence to determine the length in the first one??
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.