next up previous contents index
Next: 1.7 Regular expressions Up: 1.6 Dictionaries Previous: 1.6 Dictionaries   Contents   Index

1.6.1 Efficiency issues

Although dictionaries can handle keys of any type, they are optimized to use names as keys. The performance penalty for other key types is slight, but can be exacerbated by the cost of comparison for other types. Name comparison is a constant time operation, but string comparison is not. Therefore, use names rather than strings whenever possible.



Jason Evans 2005-03-16