{"categories":[{"label":"Software Development","url":"https://skillfed.io/packages/category/software-development/17"}],"enrichment":{"capability":"Adds single-dispatch method support to Python classes, allowing methods to dispatch on the type of their first argument with independent dispatch tables per subclass.","skillfed_tags":["method-dispatch","polymorphism"],"use_cases":["Implement polymorphic behavior in class hierarchies where different subclasses need different type handlers without modifying parent dispatch tables.","Create generic data processors that handle multiple input types (int, str, list, etc.) with specialized logic for each.","Build plugin or strategy systems where handlers are registered by type and subclasses can add their own type handlers.","Write serializers or formatters that dispatch on object type to produce different output representations.","Develop type-aware method resolution in domain models where behavior depends on argument type rather than method name."],"what_it_does":"methoddispatch extends Python's functools.singledispatchmethod to allow subclasses to maintain independent dispatch tables. The standard library's singledispatchmethod (added in Python 3.8) shares a dispatch registry across all subclasses, preventing subclasses from overriding type handlers without affecting the parent class. This package solves that by providing a SingleDispatch mixin that gives each class its own registry copy.\n\nYou decorate a method with @singledispatch and then register type-specific implementations using @method.register(type). When the method is called, it dispatches to the appropriate implementation based on the type of the first argument. Subclasses can extend or override the registry independently, and you can also register implementations at runtime via add_overload() or on individual instances. Type hints are supported for automatic type inference.","worth_installing":"Yes, if you need independent dispatch tables in class hierarchies. The package solves a real limitation of functools.singledispatchmethod and has no dependencies. Dormant maintenance is acceptable here\u2014the feature is stable and unlikely to need updates. Install it for polymorphic method dispatch; avoid it if you only need single-dispatch functions (use functools.singledispatch instead)."},"id":"methoddispatch","links":{"html":"https://skillfed.io/packages/methoddispatch","md":"https://skillfed.io/packages/methoddispatch.md","pypi":"https://pypi.org/project/methoddispatch/"},"maintenance":{"status":"dormant"},"meta":{"latest_release":"2023-11-21","license_spdx":null,"license_treatment":"permissive","name":"methoddispatch","python_support":"unspecified","summary":"singledispatch decorator for class methods."},"popularity":{"monthly_downloads":98377,"position":13088,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"5.0.1"}
