pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

fix races when initializing `#[pyclass]` type objects

Open davidhewitt opened this issue 4 months ago • 4 comments

This is split from #5223 as a follow-up which enacts the changes to LazyTypeObject to use PyOnceLock, and in the process fixes #5211

Only the second commit is new, the rest is in #5223.

davidhewitt avatar Aug 20 '25 19:08 davidhewitt

CodSpeed Performance Report

Merging #5341 will not alter performance

Comparing davidhewitt:disallow-races (2046f74) with main (6af9595)

Summary

✅ 98 untouched

codspeed-hq[bot] avatar Aug 20 '25 20:08 codspeed-hq[bot]

@davidhewitt would you like a hand getting this rebased and updated for 0.28?

ngoldbaum avatar Nov 21 '25 16:11 ngoldbaum

Sure thing, the main thing that got it stuck was https://github.com/PyO3/pyo3/pull/5341#discussion_r2300036538 where someone needs to examine the semantics of class attribute initialization and decide what we want to guarantee.

davidhewitt avatar Nov 21 '25 20:11 davidhewitt

@davidhewitt FYI - I just force-pushed a rebase to this branch. The only nontrivial bit was the fix for the conflict with https://github.com/PyO3/pyo3/commit/85e6507f261e8a288fc699cb25bd6fd6986d2101#diff-f97e0150474170093c7508d4ac482d2ab24d5325468b860c85aa4da13024917a, but I think I have it right given that the tests pass for me.

ngoldbaum avatar Dec 05 '25 20:12 ngoldbaum