Skip to content

gh-101815: remove functools.cached_property key sharing doc warnings #101816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

carljm
Copy link
Member

@carljm carljm commented Feb 10, 2023

@carljm
Copy link
Member Author

carljm commented Feb 10, 2023

Tbh I am not sure it even makes sense to mention the added memory usage from __dict__ access at all. It's a bit strange to mention that and then immediately recommend @cache as an alternative, which has a much higher likelihood of causing excessive memory use, since it creates an unbounded cache which indefinitely holds strong references to every instance the cached property is ever accessed on.

* main: (760 commits)
  pythonGH-104102: Optimize `pathlib.Path.glob()` handling of `../` pattern segments (pythonGH-104103)
  pythonGH-104104: Optimize `pathlib.Path.glob()` by avoiding repeated calls to `os.path.normcase()` (pythonGH-104105)
  pythongh-103822: [Calendar] change return value to enum for day and month APIs (pythonGH-103827)
  pythongh-65022: Fix description of tuple return value in copyreg (python#103892)
  pythonGH-103525: Improve exception message from `pathlib.PurePath()` (pythonGH-103526)
  pythongh-84436: Add integration C API tests for immortal objects (pythongh-103962)
  pythongh-103743: Add PyUnstable_Object_GC_NewWithExtraData (pythonGH-103744)
  pythongh-102997: Update Windows installer to SQLite 3.41.2. (python#102999)
  pythonGH-103484: Fix redirected permanently URLs (python#104001)
  Improve assert_type phrasing (python#104081)
  pythongh-102997: Update macOS installer to SQLite 3.41.2. (pythonGH-102998)
  pythonGH-103472: close response in HTTPConnection._tunnel (python#103473)
  pythongh-88496: IDLE - fix another test on macOS (python#104075)
  pythongh-94673: Hide Objects in PyTypeObject Behind Accessors (pythongh-104074)
  pythongh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter (pythongh-104072)
  pythongh-104016: Skip test for deeply neste f-strings on wasi (python#104071)
  pythongh-104057: Fix direct invocation of test_super (python#104064)
  pythongh-87092: Expose assembler to unit tests (python#103988)
  pythongh-97696: asyncio eager tasks factory (python#102853)
  pythongh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (pythongh-104054)
  ...
@carljm carljm changed the title gh-101815: fix functools.cached_property key sharing doc warnings gh-101815: remove functools.cached_property key sharing doc warnings May 3, 2023
@carljm
Copy link
Member Author

carljm commented May 3, 2023

See the issue for detailed discussion of the current situation with key-sharing and instance memory use in 3.12.

Because the key-sharing implementation is now quite different than what is described in PEP 412 (and PEPs are not living documentation), I think at the very least it is now misleading to link PEP 412 in this documentation.

These performance and memory optimization details are undocumented and subject to change, and their exact impact is very dependent on details of the usage patterns. In most cases the scale of these memory effects will not be significant in comparison to the memory impact of the actual caching strategy chosen. I don't think it serves users well to either go into great detail on the exact behavior of instance key sharing here, or to make vague general statements that may or may not be true in any particular case.

@carljm carljm requested a review from ambv May 3, 2023 00:29
@carljm
Copy link
Member Author

carljm commented May 3, 2023

@rhettinger do you have opinions on what we should include in this documentation here?

Also requesting review from @ambv, since this has been sitting for quite a while without review.

carljm and others added 2 commits May 15, 2023 09:05
* main: (204 commits)
  pythongh-101819: Fix _io clinic input for unused base class method stubs (python#104418)
  pythongh-101819: Isolate `_io` (python#101948)
  Bump mypy from 1.2.0 to 1.3.0 in /Tools/clinic (python#104501)
  pythongh-104494: Update certain Tkinter pack/place tests for Tk 8.7 errors (python#104495)
  pythongh-104050: Run mypy on `clinic.py` in CI (python#104421)
  pythongh-104490: Consistently define phony make targets (python#104491)
  pythongh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined (python#104473)
  pythongh-104487: PYTHON_FOR_REGEN must be minimum Python 3.10 (python#104488)
  pythongh-101282: move BOLT config after PGO (pythongh-104493)
  pythongh-104469 Convert _testcapi/float.c to use AC (pythongh-104470)
  pythongh-104456: Fix ref leak in _ctypes.COMError (python#104457)
  pythongh-98539: Make _SSLTransportProtocol.abort() safe to call when closed (python#104474)
  pythongh-104337: Clarify random.gammavariate doc entry  (python#104410)
  Minor improvements to typing docs (python#104465)
  pythongh-87092: avoid gcc warning on uninitialized struct field in assemble.c (python#104460)
  pythonGH-71383: IDLE - Document testing subsets of modules (python#104463)
  pythongh-104454: Fix refleak in AttributeError_reduce (python#104455)
  pythongh-75710: IDLE - add docstrings and comments to editor module (python#104446)
  pythongh-91896: Revert some very noisy DeprecationWarnings for `ByteString` (python#104424)
  Add a mention of PYTHONBREAKPOINT to breakpoint() docs (python#104430)
  ...
@ambv ambv added the needs backport to 3.12 only security fixes label Dec 9, 2023
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.13 bugs and security fixes label May 9, 2024
@hugovk hugovk removed the needs backport to 3.12 only security fixes label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

functools.cached_property doc warnings about key-sharing are obsolete
5 participants