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 — gh-135228: Create __dict__ and __weakref__ descriptors for object by encukou · Pull Request #136966 · python/cpython Conversation
|
|
I can polish this, but I think it'd be better to target 3.15, and follow through a bit more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Here's a polished version: the descriptors are made for And since they're the same for all objects, they can be shared across all types in an interpreter -- that is, cached in interpreter state. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This now partially reverts #137047. I don't think keeping |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is a nice improvement! I think there's risk this will break some advanced introspection code, similar to the change you had to make to inspect, but if it goes in early in the 3.15 cycle, that should be OK.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I suggest to wait some time, maybe until 3.14.1, so we can have chance to get some feedback about an alternate approach and decide whether it is worth to backport this approach to 3.14. We may also find completely different solution of the original problem in 3.15. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Jelle Zijlstra <[email protected]>
Definitely! Personally, I don't think this should be backported at all. (But I wouldn't have backported #137047 to a RC either if that was up to me...) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ct (pythonGH-136966) This partially reverts python#137047, keeping the tests for GC collectability of the original class that dataclass adds `__slots__` to. The reference leaks solved there are instead solved by having the `__dict__` & `__weakref__` descriptors not tied to (and referencing) their class. Instead, they're shared between all classes that need them (within an interpreter). The `__objclass__` ol the descriptors is set to `object`, since these descriptors work with *any* object. (The appropriate checks were already made in the get/set code, so the `__objclass__` check was redundant.) The repr of these descriptors (and any others whose `__objclass__` is `object`) now doesn't mention the objclass. This change required adjustment of introspection code that checks `__objclass__` to determine an object's “own” (i.e. not inherited) `__dict__`. Third-party code that does similar introspection of the internals will also need adjusting. Co-authored-by: Jelle Zijlstra <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.