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

OverloadingFixed-1.11.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

OverloadingFixed-1.11-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file OverloadingFixed-1.11.tar.gz.

File metadata

  • Download URL: OverloadingFixed-1.11.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for OverloadingFixed-1.11.tar.gz
Algorithm Hash digest
SHA256 cfde14d00f1f6ac9723a117072a1b2b7633e07beffb132181329d53aa1be44b2
MD5 b56d32809d1419b5f4f23b733bfae6a8
BLAKE2b-256 aefe01f17c498f5d026393bd4cdd78b7a6108150e666dd68c157a4bb38b92aed

See more details on using hashes here.

File details

Details for the file OverloadingFixed-1.11-py3-none-any.whl.

File metadata

  • Download URL: OverloadingFixed-1.11-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for OverloadingFixed-1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 b453b794e6a8c5e1bfa49a4c4c8c016e63240f0616b319869e2e5360d505bd23
MD5 f84c17cc3eb8edd0506e93d59f9ca7a6
BLAKE2b-256 c21587a57cbaac6ce0ca559302c5592875d4041799fafb00be1f19c37e4b7482

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