Kristján Valur Jónsson wrote: > Running regular python code through a profiler, and especially code that relies much on the use of > __getattr__() to emulate attribute access, will show hideous amounts of time spent formatting > attribute exceptions that get thrown away. > > Any thoughts on how to do this better? If the time is being spent in PyErr_Format, how far could you get adding a dedicated function for creating AttributeErrors? Something along the lines of: PyErr_AttributeError(PyObject *object, PyObject *attr_name) It would then be possible to modify AttributeError to have obj_type and attr_name attributes (holding the type name and the name of the missing attribute), so that any string formatting could be deferred until repr() was called on the AttributeError instance. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
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