Skip to content

Commit 8320eae

Browse files
committed
Update comments
1 parent c6f345e commit 8320eae

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

mypyc/codegen/emitclass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,8 @@ def generate_getter(cl: ClassIR, attr: str, rtype: RType, emitter: Emitter) -> N
11741174
#
11751175
# Final attributes are never rebound (no setter), so there is no concurrent
11761176
# writer to race with: a plain load + incref is safe. Use the cheaper
1177-
# CPy_GetAttrRefFinal, which skips the try-incref/re-validation machinery.
1177+
# CPy_GetAttrRefFinal, which skips the try-incref and _Py_NewRefWithLock
1178+
# slow path entirely (an unconditional Py_INCREF needs no maybe-weakref).
11781179
# This getter is generated per defining class, so a direct membership test
11791180
# matches the read-only getset table above (no need to walk the MRO).
11801181
if attr in cl.final_attributes:

mypyc/lib-rt/pythonsupport.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ static inline PyObject *CPy_GetAttrRef(PyObject **field) {
7878
// use-after-free race that CPy_GetAttrRef guards against cannot happen: the field
7979
// holds a strong reference for the object's whole lifetime, and any thread reading
8080
// it necessarily holds 'self', which keeps the value alive. So the try-incref +
81-
// _Py_NewRefWithLock fallback are unnecessary here -- a
82-
// plain load + Py_INCREF is safe. A cross-thread Py_INCREF is an unconditional
81+
// _Py_NewRefWithLock fallback are unnecessary here -- a plain load + Py_INCREF is
82+
// safe. A cross-thread Py_INCREF is an unconditional
8383
// atomic add on ob_ref_shared, so (unlike CPy_GetAttrRef's try-incref) it needs no
8484
// maybe-weakref and has no slow path. The load is relaxed rather than acquire: the
8585
// reader reached 'self' through a synchronization edge (self's own publication)
@@ -99,8 +99,8 @@ static inline PyObject *CPy_GetAttrRefFinal(PyObject **field) {
9999
// CPy_GetAttrRef reads the field optimistically without holding any lock the
100100
// writer also takes, so a reader can load the old pointer and then try to take a
101101
// reference after this store. The old value must therefore stay alive until every
102-
// thread has passed a quiescent point, which is
103-
// exactly what a QSBR-deferred decref guarantees. So all mortal old values are
102+
// thread has passed a quiescent point, which is exactly what a QSBR-deferred
103+
// decref guarantees. So all mortal old values are
104104
// reclaimed via _PyObject_XDecRefDelayed, matching CPython's own replace-a-slot
105105
// paths (e.g. _PyObject_SetDict / _PyObject_SetManagedDict).
106106
//

0 commit comments

Comments
 (0)