Mercurial > cpython-lru_cache-weakref
diff Modules/operator.c @ 37756:7b2e436a4a21 legacy-trunk
Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
using a custom, nearly-identical macro. This probably changes how some of
these functions are compiled, which may result in fractionally slower (or
faster) execution. Considering the nature of traversal, visiting much of the
address space in unpredictable patterns, I'd argue the code readability and
maintainability is well worth it ;P
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Sat, 15 Apr 2006 21:47:09 +0000 |
| parents | 6a9c7165b17b |
| children | ab4e65c809e6 |
line wrap: on
line diff
--- a/Modules/operator.c Sat Apr 15 21:41:56 2006 +0000 +++ b/Modules/operator.c Sat Apr 15 21:47:09 2006 +0000 @@ -358,8 +358,7 @@ static int itemgetter_traverse(itemgetterobject *ig, visitproc visit, void *arg) { - if (ig->item) - return visit(ig->item, arg); + Py_VISIT(ig->item); return 0; } @@ -497,8 +496,7 @@ static int attrgetter_traverse(attrgetterobject *ag, visitproc visit, void *arg) { - if (ag->attr) - return visit(ag->attr, arg); + Py_VISIT(ag->attr); return 0; }
