Jeff Epler wrote: > Using dict subclasses in eval() and exec > ---------------------------------------- > > With the attached patch, you can now use a dict subclass which implements > __getitem__ as the global or builtin namespace for eval() and exec. > > If you do not use the feature, the performance impact is low (<2%). > The fast case adds only one test+branch to each eval_code() call (to > set 'fastglobals' and 'slowbuiltins'), each lookup in globals (to > check 'fastglobals'), and each lookup in builtins (to check 'slowbuiltins'). > > If you do use the feature, the performance impact is unfortunately > quite substantial (400%). > > If you use subclasses of dict with eval()/exec, but do not define __getitem__, > the performance penalty is modest (~10%). If all you want is a way to define a default value for a failing dictionary lookup, wouldn't it be better to simply add this feature to the standard dictionary implementation ? I don't think that many people will use this feature, yet everybody would pay for the performance hit. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH _______________________________________________________________________ eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,... Python Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
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