{"id":13688750,"url":"https://github.com/beartype/plum","last_synced_at":"2026-03-17T10:03:27.142Z","repository":{"id":39499690,"uuid":"110279931","full_name":"beartype/plum","owner":"beartype","description":"Multiple dispatch in Python","archived":false,"fork":false,"pushed_at":"2026-01-25T13:46:04.000Z","size":13501,"stargazers_count":628,"open_issues_count":50,"forks_count":28,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-01-26T05:54:28.651Z","etag":null,"topics":["multiple-dispatch","python"],"latest_commit_sha":null,"homepage":"https://beartype.github.io/plum","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beartype.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-11-10T18:32:04.000Z","updated_at":"2026-01-25T13:46:00.000Z","dependencies_parsed_at":"2026-02-19T14:03:45.585Z","dependency_job_id":null,"html_url":"https://github.com/beartype/plum","commit_stats":{"total_commits":638,"total_committers":13,"mean_commits":49.07692307692308,"dds":"0.21159874608150475","last_synced_commit":"bad8ae6be8dbe6a7d08a10f47d9d2a6b75fd472d"},"previous_names":["wesselb/plum"],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/beartype/plum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beartype%2Fplum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beartype%2Fplum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beartype%2Fplum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beartype%2Fplum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beartype","download_url":"https://codeload.github.com/beartype/plum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beartype%2Fplum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29616961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multiple-dispatch","python"],"created_at":"2024-08-02T15:01:21.726Z","updated_at":"2026-02-19T14:06:54.327Z","avatar_url":"https://github.com/beartype.png","language":"Python","readme":"# [Plum: Multiple Dispatch in Python](https://github.com/beartype/plum)\n\n[![DOI](https://zenodo.org/badge/110279931.svg)](https://zenodo.org/badge/latestdoi/110279931)\n[![CI](https://github.com/beartype/plum/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/beartype/plum/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/beartype/plum/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/beartype/plum?branch=master)\n[![Latest Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://beartype.github.io/plum)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nEverybody likes multiple dispatch, just like everybody likes plums.\n\nThe design philosophy of Plum is to provide an implementation of multiple dispatch that is Pythonic, yet close to how [Julia](http://julialang.org/) does it.\n[See here for a comparison between Plum, `multipledispatch`, and `multimethod`.](https://beartype.github.io/plum/comparison.html)\n\n*Note:*\nPlum 2 is now powered by [Beartype](https://github.com/beartype/beartype)!\nIf you notice any issues with the new release, please open an issue.\n\n# Installation\n\nPlum requires Python 3.10 or higher.\n\n```bash\npip install plum-dispatch\n```\n\n# [Documentation](https://beartype.github.io/plum)\n\nSee [here](https://beartype.github.io/plum).\n\n# What's This?\n\nPlum brings your type annotations to life:\n\n```python\nfrom numbers import Number\n\nfrom plum import dispatch\n\n\n@dispatch\ndef f(x: str):\n    return \"This is a string!\"\n\n\n@dispatch\ndef f(x: int):\n    return \"This is an integer!\"\n\n\n@dispatch\ndef f(x: Number):\n    return \"This is a number, but I don't know which type.\"\n```\n\n```python\n\u003e\u003e\u003e f(\"1\")\n'This is a string!'\n\n\u003e\u003e\u003e f(1)\n'This is an integer!'\n\n\u003e\u003e\u003e f(1.0)\n'This is a number, but I don't know which type.'\n\n\u003e\u003e\u003e f(object())\nNotFoundLookupError: `f(\u003cobject object at 0x7fd3b01cd330\u003e)` could not be resolved.\n\nClosest candidates are the following:\n    f(x: str)\n        \u003cfunction f at 0x7fd400644ee0\u003e @ /\u003cipython-input-2-c9f6cdbea9f3\u003e:6\n    f(x: int)\n        \u003cfunction f at 0x7fd3a0235ca0\u003e @ /\u003cipython-input-2-c9f6cdbea9f3\u003e:11\n    f(x: numbers.Number)\n        \u003cfunction f at 0x7fd3a0235d30\u003e @ /\u003cipython-input-2-c9f6cdbea9f3\u003e:16\n```\n\n\n\u003e [!IMPORTANT]\n\u003e Dispatch, as implemented by Plum, is based on the _positional_ arguments to a function.\n\u003e Keyword arguments are not used in the decision making for which method to call.\n\u003e In particular, this means that _positional arguments without a default value must\n\u003e always be given as positional arguments_!\n\u003e\n\u003e Example:\n\u003e ```python\n\u003e from plum import dispatch\n\u003e\n\u003e @dispatch\n\u003e def f(x: int):\n\u003e    return x\n\u003e\n\u003e \u003e\u003e\u003e f(1)        # OK\n\u003e 1\n\u003e\n\u003e \u003e\u003e try: f(x=1)  # Not OK\n\u003e ... except Exception as e: print(f\"{type(e).__name__}: {e}\")\n\u003e NotFoundLookupError: `f()` could not be resolved...\n\u003e ```\n\n\nThis also works for multiple arguments, enabling some neat design patterns:\n\n```python\nfrom numbers import Number, Real, Rational\n\nfrom plum import dispatch\n\n\n@dispatch\ndef multiply(x: Number, y: Number):\n    return \"Performing fallback implementation of multiplication...\"\n\n\n@dispatch\ndef multiply(x: Real, y: Real):\n    return \"Performing specialised implementation for reals...\"\n\n\n@dispatch\ndef multiply(x: Rational, y: Rational):\n    return \"Performing specialised implementation for rationals...\"\n```\n\n```python\n\u003e\u003e\u003e multiply(1, 1)\n'Performing specialised implementation for rationals...'\n\n\u003e\u003e\u003e multiply(1.0, 1.0)\n'Performing specialised implementation for reals...'\n\n\u003e\u003e\u003e multiply(1j, 1j)\n'Performing fallback implementation of multiplication...'\n\n\u003e\u003e\u003e multiply(1, 1.0)  # For mixed types, it automatically chooses the right optimisation!\n'Performing specialised implementation for reals...'\n```\n# Projects Using Plum\n\nThe following projects are using Plum to do multiple dispatch!\nWould you like to add your project here?\nPlease feel free to open a PR to add it to the list!\n\n- [Coordinax](https://github.com/GalacticDynamics/coordinax) implements coordinates in JAX.\n- [`fasttransform`](https://github.com/AnswerDotAI/fasttransform) provides the main building block of data pipelines in `fastai`.\n- [GPAR](https://github.com/wesselb/gpar) is an implementation of the [Gaussian Process Autoregressive Model](https://arxiv.org/abs/1802.07182).\n- [GPCM](https://github.com/wesselb/gpcm) is an implementation of various [Gaussian Process Convolution Models](https://arxiv.org/abs/2203.06997).\n- [Galax](https://github.com/GalacticDynamics/galax) does galactic and gravitational dynamics.\n- [Geometric Kernels](https://github.com/GPflow/GeometricKernels) implements kernels on non-Euclidean spaces, such as Riemannian manifolds, graphs, and meshes.\n- [LAB](https://github.com/wesselb/lab) uses Plum to provide backend-agnostic linear algebra (something that works with PyTorch/TF/JAX/etc).\n- [MLKernels](https://github.com/wesselb/mlkernels) implements standard kernels.\n- [MMEval](https://github.com/open-mmlab/mmeval) is a unified evaluation library for multiple machine learning libraries.\n- [Matrix](https://github.com/wesselb/matrix) extends LAB and implements structured matrix types, such as low-rank matrices and Kronecker products.\n- [NetKet](https://github.com/netket/netket), a library for machine learning with JAX/Flax targeted at quantum physics, uses Plum extensively to pick the right, efficient implementation for a large combination of objects that interact.\n- [NeuralProcesses](https://github.com/wesselb/neuralprocesses) is a framework for composing Neural Processes.\n- [OILMM](https://github.com/wesselb/oilmm) is an implementation of the [Orthogonal Linear Mixing Model](https://arxiv.org/abs/1911.06287).\n- [PySAGES](https://github.com/SSAGESLabs/PySAGES) is a suite for advanced general ensemble simulations.\n- [Quax](https://github.com/patrick-kidger/quax) implements multiple dispatch over abstract array types in JAX.\n- [Unxt](https://github.com/GalacticDynamics/unxt) implements unitful quantities in JAX.\n- [Varz](https://github.com/wesselb/varz) uses Plum to provide backend-agnostic tools for non-linear optimisation.\n\n[See the docs for a comparison of Plum to other implementations of multiple dispatch.](https://beartype.github.io/plum/comparison.html)\n","funding_links":[],"categories":["Python","👀 Status: *lookin' awesome*"],"sub_categories":["Development"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeartype%2Fplum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeartype%2Fplum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeartype%2Fplum/lists"}