python list boundary
Is there a boundary on list and dictionary in开发者_运维百科 python? if there is, what is the limit?
I think by boundary you mean whether there is an upper bound on the number of elements in a list
or dict
. Python does not define any limits on them, so they can be as big as the memory available on your machine permits.
Actually, currently hash implementation for inner Python objects use 32 bit hashes --so, at a point close to 2^32 elements on a dictionary (assuming you have memory for that much), you will start to have a lot of collisions, and will have a significant slow down in dictionary usage. But that won't prevent it from working.
(Python devels are looking at making this hash 64 bit in future builds, so this is no longer an issue).
As for absolute limit, there is none - the limiting factor is the available system memory.
The amount of memory you have is the limit.
精彩评论