Bartc <b...@freeuk.com>: > (In the case of Python, the main obstacle is that a constant name from > inside an imported module is not visible when this module is compiled > to byte-code. So it has to assume it can be anything.)
Which it can. Optimizing for naive floating-point constants could be done but has barely any significance in most Python code. Numeric computations are carried out in separate native plugins. Most Python code deals with encapsulated objects whose innards are hidden and whose only semantics are defined by the access methods. New implementations or derived objects can be plugged in transparently. A case in point are the so-called file-like objects. They are a simple, elegant concept. I can come up with new file-like objects without any common pedigree with some predefined classes and incorporate them with a lot of utility classes. That elegant dynamism comes at a cost: method lookup is not a constant memory offset. Rather, it is a dictionary lookup. Marko -- https://mail.python.org/mailman/listinfo/python-list