weakrefmethod
A WeakMethod class for storing bound methods using weak references.
What it is and what it does
WeakMethod is a utility for storing references to bound methods without preventing their parent object from being garbage collected. This package backports Python 3.4's standard library WeakMethod class to Python 2.6 and 2.7, allowing developers on those older versions to use weak method references in their code.
The package has no runtime dependencies and is a pure-Python implementation. However, it targets Python versions that are no longer actively maintained. Installing this package makes sense only if you are maintaining legacy Python 2 code that specifically needs weak method storage.
Use it for:
- Prevent memory leaks in Python 2 code by storing weak references to bound methods instead of strong references
- Implement observer patterns or event handlers in Python 2 that don't keep objects alive
- Maintain legacy Python 2.6 or 2.7 projects that require weak method references without reimplementing the logic
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a WeakMethod class for storing bound methods using weak references, backported to Python 2.6 and 2.7 from Python 3.4's standard library.
No, unless you are actively maintaining Python 2.6 or 2.7 code. The package is unmaintained (last release 2016-07-18), and modern Python versions include WeakMethod in the standard library. For any new or current projects, use the built-in weakref.WeakMethod instead.
Install
weakrefmethod on PyPI
pip
pip install weakrefmethoduv
uv add weakrefmethodpoetry
poetry add weakrefmethodInstalling weakrefmethod
Before you install
High install friction due to source distribution only. The package is aging—last release in 2016, no updates since then—and targets Python 2.6 and 2.7, which are long out of support.
License in practice
Licensed under the Python Software Foundation License (permissive). No restrictions on use, modification, or distribution in your own code.
Quickstart
pip install weakrefmethod
from weakrefmethod import WeakMethod
class MyClass:
def method(self):
pass
obj = MyClass()
weak_method = WeakMethod(obj.method)
Package targets Python 2.6 and 2.7, which are no longer supported. WeakMethod is available in the standard library for Python 3.4 and later.
Verify before relying
- Whether this package actually works on modern Python versions despite targeting only Python 2.6–2.7
- Whether any real-world projects still depend on this backport or if it is purely historical
- Current status of Python 2 support in production environments
Package facts
| License | PSF (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | aging — 3,679 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,952/month — #14,899 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: weakrefmethod-1.0.3.tar.gz
Keywords: weakref, WeakMethod
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
backports.weakrefBackports the `weakref.finalize` class from…
permissive · top 5,000 on PyPI
backports.tempfileProvides the TemporaryDirectory context manager…
permissive · top 5,000 on PyPI
linecache2Provides a backport of Python's linecache…
permissive · top 5,000 on PyPI
objsizeMeasures the complete memory footprint of…
permissive · top 5,000 on PyPI
cached_methodProvides a method-level caching decorator that…
permissive · top 15,000 on PyPI
backrefsBackrefs extends Python's re and regex…
permissive · top 5,000 on PyPI
HTMLParserProvides HTMLParser from Python 2.7 as a…
permissive · top 15,000 on PyPI
traceback2Provides a backport of Python's traceback…
permissive · top 5,000 on PyPI
backports.zstdProvides Zstandard compression support for…
permissive · top 1,000 on PyPI
jsonrefjsonref dereferences JSON Reference objects…
permissive · top 1,000 on PyPI