Do Dictionaries have a key length limit?
Question: I was wondering if Python had a limit on the length of a dictionary key.

For clarification, I'm not talking about the number of keys, but the length of
each individual key. I'm going to be building my dictionaries based on dynamic
values (after validation), but I'm not sure if I should be taking length into
account in this case.


Answer: Here's a bit of sample code:

    
    
    from string import ascii_letters
    from random import choice
    
    def make_str(length):
        return "".join(choice(ascii_letters) for i in range(length))
    
    test_dict = {make_str(10000000): i for i in range(5)}
    

Conclusion: Python will quite happily use a 10-million-character string as a
dict key.

