pokerfast
Fast Texas hold'em primitives: a table-driven 7-card evaluator, a lean 6-max no-limit engine, and runtime accelerators for pokerkit.
Four independent pieces. Take whichever you need — none of them requires the others.
| you want | use | against pokerkit |
|---|---|---|
| compare 7-card hands | eval7 |
74x (1 core) → 331x (4 cores) |
| play out millions of hands | FastHand |
45x (1 core) → 160x (4 cores) |
| keep pokerkit, lose the cost | pokerfast.patches |
~2x on the evaluation path |
| exact multi-way equity | pokerfast.equity |
C++ (OMPEval), compiled into the wheel |
The speedup grows with core count, because the two engines scale in opposite directions on a free-threaded build. See Benchmarks.
Install
pip install pokerfast # core: eval7 + FastHand
pip install "pokerfast[pokerkit]" # + the pokerkit patches
1. eval7 — 7-card evaluation
from pokerfast import eval7
eval7(('As', 'Ks', 'Qs', 'Js', 'Ts', '2c', '3d')) # royal flush
A rank-histogram evaluator with two precomputed 8192-entry tables. One pass over seven cards, a flush test, a straight lookup, a branch on the count pattern — no enumeration of the 21 five-card combinations.
Only the ORDER is defined. The integer is not a hand rank anyone else's code will recognise: compare two of them, don't interpret one. The test suite checks the induced order against pokerkit over thousands of random hands, with ties counted separately so an evaluator that called everything equal could not pass, plus an explicit sweep of every category (random deals almost never produce a steel wheel).
2. FastHand — a 6-max NLHE engine
from pokerfast import FastHand
h = FastHand() # deal 6 players, 100/200 blinds
while not h.done:
space = h.get_action_space() # {'call': 200, 'fold': 0, 'min_bet': 400, ...}
h.call()
h.state.payoffs
pokerkit is a general, validating framework for dozens of variants, and that generality costs per action. This implements exactly one game — 6-max NLHE, cash mode, fixed blinds, one runout — where the state is a few integer lists, an action is a few additions, and a snapshot is a list copy.
Why you can trust it: tests/test_engine.py is a differential test. It
drives this engine and pokerkit through the same random action sequence and
compares the action space, the exact chip amounts, turn order, pot, board
length and the per-street action log at every step, over hundreds of hands,
with raises over-sampled at the extremes because the min-raise increment and
all-in-for-less rules are where engines go wrong.
Observers
Watch the action stream without re-deriving it:
class Log:
def __init__(self): self.events = []
def action(self, seat, amount): self.events.append((seat, amount))
def board(self, street, cards): self.events.append((street, cards))
def clone(self): ... # called on deepcopy
h = FastHand(observer=Log())
clone() matters: a branch must not write history back into the position it
branched from. Amounts are -1 for a fold, 0 for a check, chips otherwise.
3. pokerfast.patches — make pokerkit itself faster
When you need pokerkit's exact semantics but not its cost:
from pokerfast import patches
patches.install_all()
Nothing in site-packages is modified — these are in-process monkey-patches:
- an identity
__deepcopy__on pokerkit's frozen dataclasses (copying an immutable object is pure waste), applied only to classes verified to declare no mutable field; - memoisation of
Lookup._get_keyand<HandType>.from_game; - a tuple fast path for
Card.clean.
Guarded. The dangerous failure isn't "the attribute is gone" — that raises,
and is safe. It's "the attribute is still there and means something else",
which is silent. So the version is pinned, the signatures of everything patched
are fingerprinted, and a mismatch disables the patches loudly rather than
applying one that was never verified. POKERFAST_STRICT=0 overrides, once
you've checked it yourself.
4. pokerfast.equity — exact equity and a C++ evaluator
OMPEval, compiled into the wheel. No
compiler needed: pip install pokerfast gets a prebuilt library on
| OS | CPUs |
|---|---|
| Linux (glibc 2.28+, and musl/Alpine) | x86-64, ARM64 |
| macOS | Intel, Apple Silicon |
| Windows | x86-64, ARM64 |
from pokerfast import equity
equity.equity_vs_random('AhKd', '2c3d4h5s6c') # vs one random hand
equity.equity_vs_random_many([('AhKd', '2c3d4h5s6c'), ('7c7d', '')])
equity.equity(['AhKd', 'QQ+,AKs', 'random'], board='2c3d4h') # up to 6 players
equity.equity(['AhAd', 'KK'], dead='Ks', exact=False, stdev=1e-3, threads=0)
equity.evaluate([('As', 'Ks', 'Qs', 'Js', 'Ts', '2c', '3d')]) # order only
equity() takes OMPEval range syntax per player ('AhKd', 'QQ+,AKs,T9s',
'random'), exact enumeration by default or Monte Carlo with exact=False.
How it ships. The library has a plain C ABI and is loaded with ctypes,
not built as a CPython extension. It never links libpython, so one build per
OS and CPU serves every Python version — free-threaded 3.13t/3.14t and PyPy
included — and the wheels are tagged py3-none-<platform>. ctypes releases the
GIL for each call and the library holds no shared mutable state, so threads
calling it run in parallel.
Anywhere else, pip installs the pure-Python py3-none-any wheel: everything
except this module works, and equity.available() is False. To build the
library yourself (CMake 3.15+ and a C++11 compiler):
git clone --recursive https://github.com/wesboyt/pokerfast
pip install ./pokerfast # builds from source
or build just the library and point POKERFAST_OMPEVAL_LIB at it:
cmake -S native -B native/build && cmake --build native/build --config Release
Why you can trust it: tests/test_equity.py checks the evaluator's order
against eval7 (itself differentially tested against pokerkit), and exact
equities — heads-up, multiway, with dead cards — against brute-force
enumeration of every runout, to 1e-12. Every published wheel is installed and
tested on its own platform before release.
The OMPEval sources are patched at build time, in the build tree (the
submodule is never modified), with asserted anchors — see NOTICE.
Environment variables
| variable | default | effect |
|---|---|---|
POKERFAST_TABLE_EVAL |
1 |
0 routes showdowns through pokerkit instead |
POKERFAST_STRICT |
1 |
0 patches pokerkit despite a fingerprint mismatch |
POKERFAST_EVAL_CACHE |
65536 |
Lookup._get_key cache size |
POKERFAST_FROMGAME_CACHE |
32768 |
from_game cache size |
POKERFAST_OMPEVAL_LIB |
— | path to a self-built OMPEval library |
Tests
pip install "pokerfast[test]"
pytest
The differential tests need pokerkit and are the reason to trust any of this; they skip without it, which makes the suite much weaker. Don't read a green run that skipped them as a pass.
Benchmarks
PYTHON_GIL=0 python benchmarks/benchmark.py --threads 1,2,4 --rounds 5
Paired and interleaved: every round runs both engines back to back, alternating which goes first, and reports the ratio — which survives a busy machine, because contention hits both arms. Each arm gets the same wall budget and reports how much it finished, so neither is penalised by a miscalibrated work count. The per-round ratios are printed; if they disagree with each other, the machine was too noisy and the median means nothing.
CPython 3.14.7 free-threaded, pokerkit 0.7.3, 5 rounds, 3 s per arm:
| threads | full hands played to completion | 7-card evaluation |
|---|---|---|
| 1 | 45x (5,151/s vs 116/s) | 74x (269k/s vs 3,476/s) |
| 2 | 76x (10,029/s vs 135/s) | 122x (480k/s vs 3,700/s) |
| 4 | 160x (11,110/s vs 67/s) | 331x (558k/s vs 1,610/s) |
Why the speedup grows with cores
Relative to each engine's own single-thread rate:
| threads | pokerfast | pokerkit |
|---|---|---|
| 1 | 1.00x | 1.00x |
| 2 | 1.95x | 1.17x |
| 4 | 2.16x | 0.58x |
pokerfast scales sublinearly, as you would expect. pokerkit goes backwards — at four threads it does less total work than at one. That reproduced across three separate runs (0.49x, 0.70x, 0.58x), so it is an effect rather than noise, but the cause is untested: the likely candidate is reference-count contention on shared immutable objects, which a free-threaded build turns into cache-line ping-pong between cores. Treat that as a hypothesis, not a finding.
The compounding of those two curves is the whole story: 45x becomes 160x not because pokerfast got faster, but because pokerkit got slower.
What these numbers are not
Measured on one machine — an 8-thread laptop — with an unrelated GPU training job occupying ~1.5 cores throughout. The paired ratios are protected against that; the scaling column compares an engine against itself and is only partially protected, and 8 threads was not measured at all because the machine was not free. Expect different absolutes elsewhere.
They also describe a bulk workload that plays hands to completion. If you deal one hand and inspect it, pokerkit's constant factor is irrelevant to you and you should use pokerkit — it is a far more general library, and pokerfast is only faster because it does much less.
Licence
MIT — see LICENSE. The platform wheels include a compiled copy of OMPEval
(ISC) and libdivide (zlib); their licences ship in the wheel. See NOTICE.
Metadata
Release files for pokerfast 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pokerfast-0.2.0.tar.gz | 130.3 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pokerfast-0.2.0-py3-none-win_arm64.whl | Python 3 | none | Windows ARM64 | Details |
| pokerfast-0.2.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| pokerfast-0.2.0-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details |
| pokerfast-0.2.0-py3-none-musllinux_1_2_aarch64.whl | Python 3 | none | Linux musl 1.2+ ARM64 | Details |
| pokerfast-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| pokerfast-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 | Details |
| pokerfast-0.2.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| pokerfast-0.2.0-py3-none-macosx_10_13_x86_64.whl | Python 3 | none | macOS 10.13+ x86-64 | Details |
| pokerfast-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.0 MB
Release files / pokerfast-0.2.0.tar.gz
| Download URL | pokerfast-0.2.0.tar.gz |
|---|---|
| Size | 130.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48c983ef4f6bca01c23f17280e6a31039928086b6b63f4fa5f34d91c9b8af8b2
|
|
BLAKE2b-256 checksum How to use checksums |
57cc1a289557da3792346b59f6406aa0d80b6c0e7304728c40f642a1683717f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-win_arm64.whl
| Download URL | pokerfast-0.2.0-py3-none-win_arm64.whl |
|---|---|
| Size | 102.4 kB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
db89824d016e3fee6243ff16bd9c93991fe76835abfe9e3356c5367b1306b758
|
|
BLAKE2b-256 checksum How to use checksums |
f0fb655c17b45886e8d358a4bc80f33221ced9b3f818fe69b2e34f51243f3584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-win_amd64.whl
| Download URL | pokerfast-0.2.0-py3-none-win_amd64.whl |
|---|---|
| Size | 106.9 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
580bf2914df172c9d5a8434734394ec70c338ca4ef1c330565b0d3bd20bfee51
|
|
BLAKE2b-256 checksum How to use checksums |
644c15b069a4389a023db09c45a944b5683e614b184253adab65b48c822cc288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | pokerfast-0.2.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
e6139a2e045cbf90a5b7881fcba057bd2ef44a8ff7f68cefa7414fd82601dd06
|
|
BLAKE2b-256 checksum How to use checksums |
0853a97fc466b6300646bef03681abd32761f5263dc4a871836d6ef002765dba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | pokerfast-0.2.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
852c4fa5bf950859a389d1e1cb35c3fb51374f2197665b0fbe42b861af7bf0d4
|
|
BLAKE2b-256 checksum How to use checksums |
976636ab03947154c916b90410714cd8b432e0b9e639a05f7cb23689eb643d10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pokerfast-0.2.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 106.2 kB |
| Tags | Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
8f1e1e955440112bd8e992c74579fb83f019dfd9984ffcaffba5e38bd292c6f6
|
|
BLAKE2b-256 checksum How to use checksums |
b590ac3716c14ff60533d53a712668e60d4aab47cb9280b39871a8fbbac0618d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | pokerfast-0.2.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 105.1 kB |
| Tags | Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
e2365d1b9914e3b3f43ca96672bb94577778b299978bd7a0624b5ba4ad4e2d92
|
|
BLAKE2b-256 checksum How to use checksums |
f64e0ef26a9973662e14db4c85aa7e546985def54db01bc0acabbf6076e1e532
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-macosx_11_0_arm64.whl
| Download URL | pokerfast-0.2.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 110.8 kB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b8d49bcb1df09575bc646fae1117d8db6ef657eb972c36d6d3b2ca54489fd0cb
|
|
BLAKE2b-256 checksum How to use checksums |
25755f2d8bde980e314018fe1c7e1eb16d1e2f04d442b251c61b1cfa606cd3ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-macosx_10_13_x86_64.whl
| Download URL | pokerfast-0.2.0-py3-none-macosx_10_13_x86_64.whl |
|---|---|
| Size | 112.8 kB |
| Tags | Python 3 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
d2b175e798897abebd7d3f5fee8a62ad365665a0da88f438e9f670bc51bf4389
|
|
BLAKE2b-256 checksum How to use checksums |
0693aeb6985a74683903672929f4eb3cb40a0f1bbd8ee8afb0b53e10ab065271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pokerfast-0.2.0-py3-none-any.whl
| Download URL | pokerfast-0.2.0-py3-none-any.whl |
|---|---|
| Size | 38.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51c9431dd54e57740166355b516fc0435fee445f5ed0c2c76305bdd6bb97afed
|
|
BLAKE2b-256 checksum How to use checksums |
0f79b006afa9ca509c59f37a73062c536c64986dfb3a99267056d6429c3764e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logSecurity for pokerfast 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 10 files in this release have been uploaded with provenance metadata.
Attestation for pokerfast-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.