Is it faster to loop through a Python set of number or a set of letters?
Posted
by
Scott Bartell
on Stack Overflow
See other posts from Stack Overflow
or by Scott Bartell
Published on 2012-09-10T08:07:02Z
Indexed on
2012/09/10
15:38 UTC
Read the original article
Hit count: 195
Is it faster to loop through a Python set
of numbers or a Python set
of letters given that each set is the exact same length and each item within each set is the same length? Why?
I would think that there would be a difference because letters have more possible characters [a-zA-Z] than numbers [0-9] and therefor would be more 'random' and likely affect the hashing to some extent.
numbers = set([00000,00001,00002,00003,00004,00005, ... 99999])
letters = set(['aaaaa','aaaab','aaaac','aaaad', ... 'aaabZZ']) # this is just an example, it does not actually end here
for item in numbers:
do_something()
for item in letters:
do_something()
where len(numbers) == len(letters)
Update: I am interested in Python's specific hashing algorithm and what happens behind the scenes with this implementation.
© Stack Overflow or respective owner