> GvR> I'm curious where the frequent comparisons of types come > GvR> from. > > Not to mention the several hundred comparisons to None. This is harder to analyse; I set a gdb breakpoint on the place where RichCompare gets PyType_Type, then tried to see what it does, then ignoring the breakpoint a few times. This is what I've found; I may miss important cases. In PyXML, the expression type(e) in [types.StringType, types.UnicodeType] is frequently computed. This is a sequence_contains, which in turn does two Py_EQ tests. In addition, compile.c:com_add has t = Py_BuildValue("(OO)", v, v->ob_type) PyDict_GetItem(dict, t) Again, the dictionary lookup performs Py_EQ on the tuples, which does Py_EQ on the elements. This also accounts for the RichCompare calls which receive None: v may be None, here, so t is (None, type(None)). In IDLE, the situation is similar. com_add produces many compares with types. In addition, sre.compile has type(s) in sre_compile.STRING_TYPES which is the same test as the PyXML one. Finally, there is a type-in-typetuple test inside Tkinter._cnfmerge. Regards, Martin
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