On 10/7/2013 1:15 PM, Alain Ketterlin wrote:
Terry Reedy <tjre...@udel.edu> writes:
3. Python does not mandate how namespaces are implemented. CPython
uses both dicts and, for function local namespaces, internal C arrays.
So 'names' in code can become either string keys for dicts or integer
indexes for arrays.
Well, yes, but that's an implementation detail, no?
That is why I switched from 'Python' to 'CPython'. But I note the
following: in 2.x, 'from mod import *' in a function meant that the
compile time mapping of name to index could not be used and that a
fallback to dict was necessary. So another implementation might take the
easier path and always use a dict for function locals. In 3.x, such
import are limited to module scope so that functions can always use an
array and indexes for function locals. So other implementations can take
the hint and do the same without needing a dict fallback.
In other words, 3.x changed the language to facilitate the
implementation detail.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list