Skip to content

Remove redundant attribute __slots__ in functools.partial #137329

@Locked-chess-official

Description

@Locked-chess-official

Feature or enhancement

Proposal:

class partial:
    """New function with partial application of the given arguments
    and keywords.
    """

    __slots__ = ("func", "args", "keywords", "_phcount", "_merger",
                 "__dict__", "__weakref__")
    ...

Here is the code. The "__dict__" in the __slots__ make it almost useless and might consume more memory.
I think that if there is no other affect, we can remove the __slots__. Or if we want to forbid the other attributes, we can changed the __setattribute__ and warning it then finally remove the "__dict__"

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions