Skip to main content

Function overloading for Python 3

Project description

overloading is a module that provides function and method dispatching based on the types and number of runtime arguments.

When an overloaded function is invoked, the dispatcher compares the supplied arguments to available signatures and calls the implementation providing the most accurate match:

@overload
def biggest(items: Iterable[int]):
    return max(items)

@overload
def biggest(items: Iterable[str]):
    return max(items, key=len)
>>> biggest([2, 0, 15, 8, 7])
15
>>> biggest(['a', 'abc', 'bc'])
'abc'

Features

  • Function validation during registration and comprehensive resolution rules guarantee a well-defined outcome at invocation time.

  • Supports the typing module introduced in Python 3.5.

  • Supports optional parameters.

  • Supports variadic signatures (*args and **kwargs).

  • Supports class-/staticmethods.

  • Evaluates both positional and keyword arguments.

  • No dependencies beyond the standard library

Documentation

The full documentation is available at https://overloading.readthedocs.org/.

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

overloading-0.5.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

overloading-0.5.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file overloading-0.5.0.tar.gz.

File metadata

  • Download URL: overloading-0.5.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for overloading-0.5.0.tar.gz
Algorithm Hash digest
SHA256 493f0f67211244ed6bf2acf9f3ac61fb38e8aa87834c4f0f84d8943512066588
MD5 d8c8d99965eb2208100e4adeb8b154ad
BLAKE2b-256 196cdbc5ddff9eec6b57046c11985d28ebac2f8073596a7cc903c76f26856284

See more details on using hashes here.

File details

Details for the file overloading-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for overloading-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c28d2a227cfb6bdefcfe0ded055bc620a5c784a52ecadc441f8d6c281b8bb1c1
MD5 4294b83ece23add75b6dcb06fc0641a2
BLAKE2b-256 3bd1775dec1fb1e2a600d587adfef9aafba7b0b995532b3bc63a5a927446a8ce

See more details on using hashes here.

Supported by

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