Issue 34830: functools.partial is weak referncable (original) (raw)
Issue34830
This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/79011
classification
Title: | functools.partial is weak referncable | ||
---|---|---|---|
Type: | enhancement | Stage: | resolved |
Components: | Documentation | Versions: | Python 3.7 |
process
Status: | closed | Resolution: | not a bug |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | docs@python | Nosy List: | asvetlov, docs@python, mdk, serhiy.storchaka, xtreak |
Priority: | normal | Keywords: |
Created on 2018-09-28 09:20 by mdk, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg326617 - (view) | Author: Julien Palard (mdk) * ![]() |
Date: 2018-09-28 09:20 |
According to the doc: :class:`partial` objects are like :class:`function` objects in that they are callable, weak referencable, and can have attributes. I don't understand why "weak" here, and it's the only occurence of "weak referencable" in the documentation. I don't see an object in Python being referencable but NOT weak referencable, do I miss something obvious here? | ||
msg326619 - (view) | Author: Andrew Svetlov (asvetlov) * ![]() |
Date: 2018-09-28 09:36 |
``` In [1]: import weakref In [2]: class A: ...: __slots__ = () In [3]: weakref.ref(A()) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in ----> 1 weakref.ref(A()) TypeError: cannot create weak reference to 'A' object ``` | ||
msg326621 - (view) | Author: Julien Palard (mdk) * ![]() |
Date: 2018-09-28 09:42 |
TIL. So it really make sense in this context to tell a functools.partial is weak referencable? | ||
msg326622 - (view) | Author: Andrew Svetlov (asvetlov) * ![]() |
Date: 2018-09-28 09:43 |
I think yes. | ||
msg326623 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-09-28 09:50 |
Instances of many builtin types are not weak referencable. >>> weakref.ref(0) Traceback (most recent call last): File "", line 1, in TypeError: cannot create weak reference to 'int' object >>> weakref.ref([]) Traceback (most recent call last): File "", line 1, in TypeError: cannot create weak reference to 'list' object |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:59:06 | admin | set | github: 79011 |
2018-09-28 09:50:15 | serhiy.storchaka | set | nosy: + serhiy.storchakamessages: + |
2018-09-28 09:43:58 | mdk | set | status: open -> closedresolution: not a bugstage: resolved |
2018-09-28 09:43:14 | asvetlov | set | messages: + |
2018-09-28 09:42:26 | mdk | set | messages: + |
2018-09-28 09:41:07 | xtreak | set | nosy: + xtreak |
2018-09-28 09:36:27 | asvetlov | set | nosy: + asvetlovmessages: + |
2018-09-28 09:20:44 | mdk | create |