backports.weakref
Backport of new features in Python's weakref module
Decision gist · record as of 2026-08-14
Only if you are maintaining code on Python 2.7, 3.4, 3.5, or 3.6 and need `weakref.finalize`. The package is abandoned and unmaintained since 2017, so it should not be used in new projects. On Python 3.4+, use the standard library's `weakref.finalize` directly. No known security vulnerabilities.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Only useful on Python 2.7, 3.4, 3.5, or 3.6; on Python 3.4+ you should import `finalize` directly from the standard `weakref` module instead.
- Installation is straightforward with no runtime dependencies.
- The package is abandoned as of 2017 with no recent maintenance, so it should only be used if you are stuck on Python 2.7, 3.4, 3.5, or 3.6 and cannot upgrade.
License · maintenance · safety
permissive license (permissive) — Licensed under the Python Software Foundation License, a permissive license that allows use in most contexts without restriction.
last release 2017-09-17 (3253 days) · last repo commit 2017-10-13 · 8 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,240,909 downloads/mo, #4,172 on PyPI
Alternatives
Verify before relying
pip install backports.weakref
from backports.weakref import finalize
class MyClass:
pass
obj = MyClass()
finalize(obj, print, "Object was garbage collected")- Whether this package is still compatible with modern Python tooling and dependency resolvers despite being abandoned since 2017.
What it is and what it does
This package provides a backport of `weakref.finalize`, a feature added to Python's standard `weakref` module in Python 3.4. The `finalize` class lets you register a callback function to be called when an object is garbage collected, enabling deterministic cleanup of resources tied to that object's lifetime.
It is intended only for projects that must support Python 2.7 or early Python 3.x versions (3.4–3.6) and cannot upgrade. On Python 3.4 and later, the standard library's `weakref.finalize` should be used directly. The package has no runtime dependencies and installs cleanly, but has been unmaintained since 2017.
Use it for
- Register cleanup code for Python 2.7 projects that need to run finalizers when objects are garbage collected.
- Support legacy Python 3.4–3.6 codebases that use `weakref.finalize` but cannot yet upgrade to a newer Python version.
- Provide a uniform API across old and new Python versions when backporting code from Python 3.4+.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Only if you are maintaining code on Python 2.7, 3.4, 3.5, or 3.6 and need `weakref.finalize`.
The package is abandoned and unmaintained since 2017, so it should not be used in new projects. On Python 3.4+, use the standard library's `weakref.finalize` directly. No known security vulnerabilities.
Install
backports-weakref on PyPI
Before you install
Installation is straightforward with no runtime dependencies. The package is abandoned as of 2017 with no recent maintenance, so it should only be used if you are stuck on Python 2.7, 3.4, 3.5, or 3.6 and cannot upgrade.
Only useful on Python 2.7, 3.4, 3.5, or 3.6; on Python 3.4+ you should import `finalize` directly from the standard `weakref` module instead.
License in practice
Licensed under the Python Software Foundation License, a permissive license that allows use in most contexts without restriction.
Quickstart
pip install backports.weakref
from backports.weakref import finalize
class MyClass:
pass
obj = MyClass()
finalize(obj, print, "Object was garbage collected")
Verify before relying
- Whether this package is still compatible with modern Python tooling and dependency resolvers despite being abandoned since 2017.
Package facts
| License | permissive license permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 3,253 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,240,909 / month, #4,172 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: Python Software Foundation LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules |
Evidence: backports.weakref-1.0.post1-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “weakref finalize backport”
- backports.weakrefBackports the `weakref.finalize` class from Python 3.4+ to earlier…
- weakrefmethodProvides a WeakMethod class for storing bound methods using weak…
- backports.tarfileProvides a backport of Python's tarfile module for use on Python…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also weakrefmethod · backports.tempfile · async-exit-stack · contextlib2 · traceback2 · backports.zstd · configparser · pickle5 · objsize · exceptiongroup