range() is not the best way to check range?
tac-tics
tactics40 at gmail.com
Tue Jul 18 17:34:35 EDT 2006
More information about the Python-list mailing list
Tue Jul 18 17:34:35 EDT 2006
- Previous message (by thread): range() is not the best way to check range?
- Next message (by thread): range() is not the best way to check range?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Simon Forman wrote: > To me, and perhaps others, "T = > set(xrange(0, 10000, 23))" and "n in T" are somewhat easier to read > and write than "not n % 23 and 0 <= n < 10000", YMMV. Eh? How is the first easier to read than the second?? You have a nested function call in the first! Regardless, testing if a member is part of a ranged set is always going to be slower. It's the nature of what you're doing. Building a set and then searching it takes much longer than a single modulus and subtraction (which is all an integer comparison is).
- Previous message (by thread): range() is not the best way to check range?
- Next message (by thread): range() is not the best way to check range?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list