GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Replace Py_INCREF()/Py_XINCREF() usage with Py_NewRef()/Py_XNewRef() · Issue #99300 · python/cpython Closed Labels type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionI added Py_NewRef() and Py_XNewRef() to Python 3.10 C API. IMO using them make to code easier to read and make the code looks "more correct". Examples: (A) Assign + INCREF: - result = Py_False; - Py_INCREF(result); + result = Py_NewRef(Py_False); (B) INCREF + assign: - Py_INCREF(last); - self->last = last; + self->last = Py_NewRef(last); (C) INCREF + return: - Py_XINCREF(result); - return result; + return Py_XNewRef(result); While technically, Py_INCREF() and Py_XINCREF() modify the object in-place (increment their reference counter), for me Py_NewRef() makes me sense: it creates "a new reference". The example (A) is weird: it assigns a variable to something, and only later creates a new reference. For me, the syntax with Py_NewRef() makes more sense. Examples (B) and (C) are shorter with Py_NewRef(), and again, IMO makes more sense and are more readable. Reacted by Gregory P. Smith and Erlend E. Aasland Reacted by Erlend E. Aasland Activity
MetadataMetadataAssigneesLabelstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |