Skip to main content

Add function overloading to Python

Project description

Python Function Overload

A function decorator that allows for real function overloading in Python 3. Not that typing.overload nonsense, but actual function overloading.

This module is a joke, please don't use it in production code.

Installation

You can install either install this module from the source or from PyPI using

pip install function-overload

Usage

Overload-decorated function are grouped by name. The name of the group is determined either by the name of the decorated function or by the name argument to the overload decorator.

When a overloaded function is called, the arguments are matched against the signatures of the functions in the group. The first function whose signature matches the arguments is called (in the order they were defined).

from overload import overload

@overload
def foo(x: int):
    return x + 1

@overload
def foo(x: str):
    return x + '!'

assert foo(1) == 2
assert foo('hello') == 'hello!'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

function_overload-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

function_overload-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file function_overload-0.1.0.tar.gz.

File metadata

  • Download URL: function_overload-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for function_overload-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ddae02ee8d909ac4a5ba271c8fcf62ae4c18693f2833b886df25b66bc028d81
MD5 43a7cc1f8b6199c6a3934da5bd3f7ac4
BLAKE2b-256 4097c3ec50a4f8389f0c6b6693902df96b00eda02d7a40b68eed9c9eceea99fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for function_overload-0.1.0.tar.gz:

Publisher: python-publish.yml on giulioprocopio/python-overload

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file function_overload-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for function_overload-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 274954b9ffc03f259e867b81f0c03a8e97191983642d13977f06db447b36abd7
MD5 ae7f6e9e32385b18299857dc03ac00ec
BLAKE2b-256 d729ea303395b184db70fff80e212cc9af2d071657ee317aa83bcdd92ac4aecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for function_overload-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on giulioprocopio/python-overload

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page