Mark Hammond wrote: > > Here is a bit of an idea that I first came up with some years ago. Guido's > response at the time was "sounds reasonable as long as we dont slow the > normal case down". > > To cut a long story short, I would like eval and exec to be capable of > working with arbitrary mapping objects rather than only dictionaries. The > general idea is that I can provide a class with mapping semantics, and pass > this to exec/eval. This involves a whole lot of changes: not only in the Python core, but also in extensions that rely on having real dictionaries available. Since you put out to objectives, I'd like to propose a little different approach... 1. Have eval/exec accept any mapping object as input 2. Make those two copy the content of the mapping object into real dictionaries 3. Provide a hook into the dictionary implementation that can be used to redirect KeyErrors and use that redirection to forward the request to the original mapping objects > This would give us 2 seriously cool features (that I want <wink>), should > anyone decide to write code that enables them: > > * Case insensitive namespaces. This would be very cool for COM, and as far > as I know would please the Alice people. May open up more embedding > opportunities that are lost if people feel strongly about this issue. This is covered by 1 and 2. > * Dynamic name lookups. At the moment, dynamic attribute lookups are > simple, but dynamic name lookups are hard. If I execute code "print foo", > foo _must_ pre-exist in the namespace. There is no reasonable way I can > some up with so that I can fetch "foo" as it is requested (raising the > NameError if necessary). This would also be very cool for some of the COM > work - particularly Active Scripting. This is something for 3. I guess it wouldn't cause any significant slow-down and can be imlemented with much less code than the "change all PyDict_GetItem to PyObject_GetItem" thingie. The real thing could then be done for 2.0 where PyDict_Check() would presumably not rely on an adress but some kind of inheritance scheme indicating that the object is in fact a dictionary. Cheers, -- Marc-Andre Lemburg Y2000: 245 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : ---------------------------------------------------------
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4