Skip to main content

Python Pattern Matching

Project description

Python Pattern Matching

Reusable pattern matching for Python, implemented in Cython. I originally developed this system for the Ibis Project in pure python, but it can be useful in many other contexts as well.

Examples

from koerce import match, NoMatch
from koerce.sugar import Namespace
from koerce.patterns import SomeOf, ListOf

assert match([1, 2, 3, SomeOf(int, at_least=1)], four) == four
assert match([1, 2, 3, SomeOf(int, at_least=1)], three) is NoMatch

assert match(int, 1) == 1
assert match(ListOf(int), [1, 2, 3]) == [1, 2, 3]
from dataclasses import dataclass
from koerce.sugar import match, Namespace, var
from koerce.patterns import pattern
from koerce.builder import builder

@dataclass
class A:
    x: int
    y: int

@dataclass
class B:
    x: int
    y: int
    z: float


p = Namespace(pattern, __name__)
d = Namespace(builder, __name__)

x = var("x")
y = var("y")

assert match(p.A(~x, ~y) >> d.B(x=x, y=1, z=y), A(1, 2)) == B(x=1, y=1, z=2)

More examples and a comprehensive readme are on the way.

Packages are not published to PyPI yet.

Python support follows https://numpy.org/neps/nep-0029-deprecation_policy.html

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

koerce-0.0.9.tar.gz (52.3 kB view details)

Uploaded Source

Built Distributions

koerce-0.0.9-cp312-cp312-win_amd64.whl (397.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

koerce-0.0.9-cp312-cp312-win32.whl (325.8 kB view details)

Uploaded CPython 3.12 Windows x86

koerce-0.0.9-cp312-cp312-musllinux_1_2_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

koerce-0.0.9-cp312-cp312-musllinux_1_2_i686.whl (2.9 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.2+ i686

koerce-0.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

koerce-0.0.9-cp312-cp312-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (3.1 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

koerce-0.0.9-cp312-cp312-macosx_14_0_arm64.whl (451.9 kB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

koerce-0.0.9-cp312-cp312-macosx_13_0_x86_64.whl (495.1 kB view details)

Uploaded CPython 3.12 macOS 13.0+ x86-64

koerce-0.0.9-cp311-cp311-win_amd64.whl (414.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

koerce-0.0.9-cp311-cp311-win32.whl (337.9 kB view details)

Uploaded CPython 3.11 Windows x86

koerce-0.0.9-cp311-cp311-musllinux_1_2_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

koerce-0.0.9-cp311-cp311-musllinux_1_2_i686.whl (3.0 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

koerce-0.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

koerce-0.0.9-cp311-cp311-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (3.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

koerce-0.0.9-cp311-cp311-macosx_14_0_arm64.whl (450.6 kB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

koerce-0.0.9-cp311-cp311-macosx_13_0_x86_64.whl (507.9 kB view details)

Uploaded CPython 3.11 macOS 13.0+ x86-64

koerce-0.0.9-cp310-cp310-win_amd64.whl (412.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

koerce-0.0.9-cp310-cp310-win32.whl (338.6 kB view details)

Uploaded CPython 3.10 Windows x86

koerce-0.0.9-cp310-cp310-musllinux_1_2_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

koerce-0.0.9-cp310-cp310-musllinux_1_2_i686.whl (2.6 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

koerce-0.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

koerce-0.0.9-cp310-cp310-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (2.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

koerce-0.0.9-cp310-cp310-macosx_14_0_arm64.whl (450.1 kB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

koerce-0.0.9-cp310-cp310-macosx_13_0_x86_64.whl (506.2 kB view details)

Uploaded CPython 3.10 macOS 13.0+ x86-64

File details

Details for the file koerce-0.0.9.tar.gz.

File metadata

  • Download URL: koerce-0.0.9.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9.tar.gz
Algorithm Hash digest
SHA256 800ebbe13922fe730fcad73b49336e238b4a461b21e299164b98a9b36e657ea9
MD5 2a7764b68b8436c408ab158b2c7feb42
BLAKE2b-256 6dc2eb9c92033c5c415de7412cd5f61ce6c01fdae0d8b9e8ea6405a1cd81cec7

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: koerce-0.0.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 397.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 10df1ff37ee6feb0c3bf1bf8869827b2639d4fe05ef49017210df9917fef60c5
MD5 4adf8c748273e4f11159cf0fad41928d
BLAKE2b-256 f9d65228a1d544d9eb7f836940bb09fb913c4c9cf2e75a7866138eb996a10fce

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-win32.whl.

File metadata

  • Download URL: koerce-0.0.9-cp312-cp312-win32.whl
  • Upload date:
  • Size: 325.8 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 304d3a6a5967a5b5bc661575b8a74d4d682f716e00cf63bd31eb14e704474e9e
MD5 dd800f051fc48b112538364a1b7773b1
BLAKE2b-256 06bb987bc93b1fbadf1dd5bf5efd66868bfbe628be8b69b3fdaf16c0e5c321e6

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 059fb193c72884844b008f0d1a0cc9b95bfb75b6ac0eaabc808249dab4865d94
MD5 3ebddbfbe4a1be593652b0d620782ff9
BLAKE2b-256 35cac2c6cb4fadfb7c20add79da52c3b4144a071b472702f70d8abd3af47c0f6

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e606716628a8aa72fb1f9ab0f93d87266e2eefe108744ce7d5cc7311a6bdac58
MD5 b31f7e637532ee63b43d5022fd6a49eb
BLAKE2b-256 211413a8608ef8646e494bb2cf8260179b09588653c84f0ceb7f8d93e07048c0

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ae8429b8bf6e6f88e46508d1313b57f41d9ea83265794aeaeb7ec1a7fa84078
MD5 71c540ffa03c413fe2bbd573a7f5b17c
BLAKE2b-256 1795aae28a8e351aa931d62e0b34edd4c74e3e0cc416c1df4b589ccb5fad93a9

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp312-cp312-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 daa2ebb15942a828f5159e00b532141123daafed789ca228a1403bcbf855a842
MD5 827e85707f5458aa83b51b75aa977106
BLAKE2b-256 008ebc482ad5933fb8ca052583db9d8eef1d4211099fbf3eda7ef3a4d951f90f

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 49d3155cc7975a93358604ac3204cfe18fd7bf62c855c464e8c5a2454841b761
MD5 63990d79fcca5d676c52e1152045525e
BLAKE2b-256 ff7255963bd2c51973411cee40c98acb3f634b05f03823d3be6a13f680d40fa4

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 9451aceca6666023107c1c5dc0117ed47de0471824e78a4b3ff878853a6fb5d1
MD5 a8b2feaf21b7ef6e9ecf35a1aea80f12
BLAKE2b-256 7b5da1ad749e9e25332ef31915747127cae1d5075804b92c862467d8b1932001

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: koerce-0.0.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 414.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 70ba1f2e566883572075f4bd8cd9bf8c42f3f11fea6197f3e6093c11f83a4ae7
MD5 abcbcddd76c9582c53f634354a115f36
BLAKE2b-256 037ac510f935def0f926a43204e907dcfd4004bc1f4f509c66e98137431d0739

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-win32.whl.

File metadata

  • Download URL: koerce-0.0.9-cp311-cp311-win32.whl
  • Upload date:
  • Size: 337.9 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 9796c424864d414dd702f183390150b698a8d05b1a18d0da4ae3dfbc1072e7f8
MD5 609cc6c0f0499f83d7eedd49cc6432eb
BLAKE2b-256 705f604b8ee44917a511c63e9bd77cd03604d465bc3acd6bd3d6859628e5ec27

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 059b6e5d14b719ce78140cd108317949d4536992eb51563ba1c2bc9451d9067f
MD5 82cd22be1019c1a7c461c4a196ad183b
BLAKE2b-256 0b48cda59243c67dffbd876153ec9ccfdd8bc51b72b5854fec5cce550338a45a

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 9e37863687b6e1b6470df05ff1fc8c35d1d079cd707c3f4592d484e0cac045fe
MD5 459b046c52b033d7064a2dcd09299f47
BLAKE2b-256 cbdeaa0627bec5d902e2a0e34921bb086bf73208f405156b3a2169a730395b61

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3ea9dd143965d186a2d1cd1e56781df0fe53ce63c1b0adbd3c961fa5b49617e
MD5 226d68b813ba1d0b8323eb2bd5a28df4
BLAKE2b-256 3578366dd71c0081a21c0c1a6d5d88328b718f48a3461e0758b24d4f3d073b4e

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp311-cp311-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 71902837c62dac2126a0943fec98ff20fc1ede1239d9055df8183a5ca00e4550
MD5 fc92fce059db07b0a0aa7ce60a841fc1
BLAKE2b-256 dca35e4b3cf0fe7122e7618c79155e991ca8dbf307391047d9fd08b0637e4cfb

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b6d7480f464b4dba1871b7291e731ead1baeedd3205fc53ab86c40f0b254b8bd
MD5 6b7fa555e761543dc5fb348f8e00ae5d
BLAKE2b-256 ad78b52af08ad8ac32bfaed14dd3f508eeb96fdb5f744b839fcd49be7df018ec

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp311-cp311-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 e0c66c3c4c868d7b2cbdd56daa4442f63035279128abab8e742a9c480e36899c
MD5 5ce1655139705f9d88421a0db978fb01
BLAKE2b-256 69902230943967bbfb961921cb5b3623ee122ea8d21372527e927eb96d907b23

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: koerce-0.0.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 412.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6ba23867f337552ccf881295b566017da9f0d812d841bb11fe3c8ebe72bbd017
MD5 4550051ee279b2dfb22e63bac30b70ac
BLAKE2b-256 0d86136f73b6ad8e4393c8d6418902a39fc50667709755203d3fa6294017557d

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-win32.whl.

File metadata

  • Download URL: koerce-0.0.9-cp310-cp310-win32.whl
  • Upload date:
  • Size: 338.6 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for koerce-0.0.9-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 a75de2963e8a312c2f3bf85055eba4164cf861c2e12b01a916a2e8f6e35eb420
MD5 fcf1f99f37f9beb23ce93b9e9f0b577c
BLAKE2b-256 116d72779d26c822f3fe3621b0a5e28bf01b6d16180b45936d797e143ba904a9

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d707cbbdc8598bc2c972f788447490775821d86fa09a6048eaeaf68adb14b4c5
MD5 bc0db77b300fdbd3c83fc1be204b1c8e
BLAKE2b-256 3889196620620f13c3436d5ce8bb28492fb4a09343945e793ae502cb2a6fe4ef

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 166ce9ea3ce2b78c425ef58ad1a742b6ee2ef066a741f0f841af191800788924
MD5 6b3b338ee030f6a9e027d701a37bb299
BLAKE2b-256 64833084d9e4842a75675b024b66f71f0e03bb3d3a841a2879fd926b3d040356

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2d80dd66a169072ee1c29936b9edb4deed6d362691a52d39d1bfd58873ee1358
MD5 d3918bdbd216a66be90704bd1f120ecd
BLAKE2b-256 493228b503e00c352d916b8f2ac3aa07804e43da1be3c990bc69cb28474d73de

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp310-cp310-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 684d36c0472c6d309bffef6f57cd48bafbd3b4ca0cb5fb6516e4b5997cdda280
MD5 f60fbea670d61eedd9c9edf6d2004245
BLAKE2b-256 1a167cd31ac178ea626d41ebc666be131bdea4bfd0d5be36ec150bcfedca4dfa

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f5da5520ea3682f58b791c0261cfbd9568291bc46a9dff9303c04fea9be11094
MD5 2f3512cd5dea8b097bd95ddf9d6f7f87
BLAKE2b-256 0f707f5f61ec8675cad2c7636a3a21c0fb983cced3007ec4ff8e02b438508336

See more details on using hashes here.

Provenance

File details

Details for the file koerce-0.0.9-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for koerce-0.0.9-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 ab7eabb3e8d81ed646f810b785bfbaab8c298e2c0969ee72c3133eb8e07d35f3
MD5 fddab4a5a2faf005ebfa25737fd8d769
BLAKE2b-256 adb067ec002fa5b2e81feaf3d4abc5a14c86dee888acce5e66aa8a46fd68c583

See more details on using hashes here.

Provenance

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