Christian Tismer <tismer@tismer.com> writes: > Hi Guido: > > here a simpler formulation of my question: > > I would like to create types with overridable methods. > This is supported by the new type system. > > But I'd also like to make this as fast as possible and > therefore to avoid extra dictionary lookups for methods, > especially if they are most likely not overridden. I would wonder how much this saves. How many more instructions does PyDict_GetItem(ob->ob_type->tp_dict, interned_string) take than ob->ob_type->tp_my_field->mf_my_method ? Sure, *some* but not all that many esp. if the called function is actually doing significant work. Of course, the first gets you a PyCFunctionObject* (or similar) not a function pointer and that adds a layer of overhead. In fact, this is probably the greater source of overhead (you might have to box up the arguments, allocate & deallocate the argument tuple, etc). I doubt my opinion counts here, but I think I'd prefer to see *less*, not more, methods in type object in future. Particularly if there's some way to call functions with known signatures efficiently. Unfortunately, that seems pretty hard after five minutes thinking. Cheers, M. -- I wouldn't trust the Anglo-Saxons for much anything else. Given they way English is spelled, who could trust them on _anything_ that had to do with writing things down, anyway? -- Erik Naggum, comp.lang.lisp
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