[New-bugs-announce] [issue5135] Expose simplegeneric function in functools module

Paul Moore report at bugs.python.org
Mon Feb 2 20:57:40 CET 2009


New submission from Paul Moore <p.f.moore at gmail.com>:

This patch takes the existing "simplegeneric" decorator, currently an
internal implementation detail of the pkgutil module, and exposes it as
a feature of the functools module.

Documentation and tests have been added, and the pkgutil code has been
updated to use the functools implementation.

Open issue: The syntax for registering an overload is rather manual:

    def xxx_impl(xxx):
        pass
    generic_fn.register(XXX, xxx_impl)

It might be better to make the registration function a decorator:

    @generic_fn.register(XXX)
    def xxx_impl(xxx):
        pass

However, this would involve changing the existing (working) code, and I
didn't want to do that before there was agreement that the general idea
(of exposing the functionality) was sound.

----------
assignee: ncoghlan
components: Library (Lib)
files: generic.patch
keywords: needs review, patch
messages: 80986
nosy: ncoghlan, pmoore
priority: normal
severity: normal
stage: patch review
status: open
title: Expose simplegeneric function in functools module
type: feature request
versions: Python 2.7
Added file: http://bugs.python.org/file12921/generic.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5135>
_______________________________________


More information about the New-bugs-announce mailing list