← index #646PR #529
Related · high · value 0.591
QUERY · ISSUE

Do we want to have weakref support?

openby pfalconopened 2014-06-01updated 2025-11-29
rfcpy-core

Here's another thing to consider re: completeness of language implementation: do we want to support weak referenced (weakref module)?

On one hand, it's niche feature used rarely enough. On the other hand, it's something which would pretty much help low-memory usage: ability to cache some object in memory, but safely and transparently free it if there's memory pressure.

But efficient implementation of weakrefs is expensive - each object need to grow to contain pointer to its associated weakref. Taking into account that weakrefs are rare, less runtime-efficient, but much more memory-efficient impl of having a separate mapping from obj to its weakref can be used.

Thoughts/comments are welcome.

CANDIDATE · PULL REQUEST

weakref: Add basic stub function to aid in porting.

openby andrewleechopened 2022-09-06updated 2024-05-30

This just allows most basic usages of weakref in other modules to "work" unless they test for actual cleanup via gc.collect etc.

Docs: https://docs.python.org/3/library/weakref.html#weakref.ref

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied