skillfed

lazr.delegates

Easily write objects that delegate behavior

lazr-delegates v4.0.0 661.1K downloads/30d#5,453 on PyPI
Copyleft license LGPL v3 Active released

What it is and what it does

lazr.delegates is a utility for the object composition pattern, letting you create wrapper objects that forward calls to an underlying object while maintaining interface contracts through zope.interface. It reduces boilerplate when you need to add behavior to an existing object without modifying it directly—common in plugin systems, decorators, and layered architectures.

The package works by helping you declare which object to delegate to and automatically handling method/property forwarding. It relies on zope.interface to ensure the wrapper still satisfies the original interface contract. With a single runtime dependency and support for Python 3.8 through 3.14, it integrates cleanly into projects already using the Zope ecosystem or those adopting interface-based design.

Use it for:

  • Add logging or caching behavior to an existing object without modifying its class
  • Build plugin systems where decorators wrap core objects with additional functionality
  • Implement proxy or adapter patterns while maintaining type safety through interfaces
  • Create layered architectures where each layer wraps and extends the layer below
  • Compose behavior from multiple objects while presenting a unified interface to callers

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Simplifies creating wrapper objects that delegate method and property calls to an underlying object while adding or modifying behavior through zope.interface.

Yes, if you are already using zope.interface or building systems that rely on interface-based design and composition. The package is stable, actively maintained, has no known vulnerabilities, and installs with minimal friction. It is most valuable in projects that benefit from explicit delegation and interface contracts; for simple wrapping without interface requirements, standard Python patterns may suffice.

Install

lazr-delegates on PyPI

pip

pip install lazr-delegates

uv

uv add lazr-delegates

poetry

poetry add lazr-delegates

Installing lazr.delegates

Before you install

Low friction installation with a single pure-Python dependency (zope.interface). Package is actively maintained with a recent release and supports current Python versions from 3.8 through 3.14.

License in practice

Licensed under LGPL v3 (copyleft). Any modifications to this package must be released under the same license, and derivative works must provide source code access to users.

Quickstart

pip install lazr-delegates

from lazr.delegates import delegates
from zope.interface import Interface, implementer

class IBase(Interface):
    pass

@implementer(IBase)
class Base:
    def method(self):
        return 'base'

@implementer(IBase)
@delegates('_base')
class Wrapper:
    def __init__(self, base):
        self._base = base

Verify before relying

  • Whether the package provides decorators or explicit delegation configuration beyond what the description states
  • Performance characteristics when delegating across many methods or in high-call-volume scenarios
  • Interaction patterns with zope.interface's advanced features (adapters, utilities, etc.)

Package facts

License LGPL v3 (copyleft)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — zope.interface
Maintenance actively maintained — 13 days since the last release
First released
Downloads 661,121/month — #5,453 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: lazr_delegates-4.0.0-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

object delegation patternwrapper object behaviorinterface delegationdelegate methods to another objectadd behavior to existing objectsproxy pattern implementationobject composition helper
object-compositiondesign-patternszope-ecosystem

More Software Development packages