Operator overloading for fast anonymous functions.
Project description
A placeholder uses operator overloading to create partially bound functions on-the-fly. When used in a binary expression, it will return a callable object with the other argument bound. It's useful for replacing lambda in functional programming.
Usage
from placeholder import _ # single underscore
_.age < 18 # lambda obj: obj.age < 18
_[key] ** 2 # lambda obj: obj[key] ** 2
Note _ has special meaning in other contexts, such as the previous output in interactive shells. Assign to a different name as needed.
_ is a singleton of an F class, and F expressions can also be used with functions.
from placeholder import F
-F(len) # lambda obj: -len(obj)
All applicable double underscore methods are supported. Some methods coerce types: len, bool, in.
Performance
The placeholder instance leverages functools.partial and Placeholder for optimization. It is significantly faster than similar libraries on PyPI.
Performance should generally be comparable to inlined expressions, and faster than lambda. There is an optional legacy C extension which provides a small speedup for right-bound functions in Python <3.14 only.
Placeholders are provisionally iterable, allowing access to the underlying function and bound args.
(func,) = _.age # operator.attrgetter('age')
Installation
pip install placeholder
Tests
100% branch coverage.
pytest [--cov]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file placeholder-1.6.tar.gz.
File metadata
- Download URL: placeholder-1.6.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a5d5c25634ec36e0e336ff8ce98675f66176518ae7ee92755c198747dd48bd2
|
|
| MD5 |
944e6ca4579efabff28bac8807f6ace2
|
|
| BLAKE2b-256 |
ed37e37e0e5dd77438df4799254c226fc2bec113ee38269bf29efb1fb91e8638
|
Provenance
The following attestation bundles were made for placeholder-1.6.tar.gz:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6.tar.gz -
Subject digest:
6a5d5c25634ec36e0e336ff8ce98675f66176518ae7ee92755c198747dd48bd2 - Sigstore transparency entry: 2202082055
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-py3-none-any.whl.
File metadata
- Download URL: placeholder-1.6-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1fde902a2ebb02f65c7156e07ff41bb02aee9f7d98482d242963c3514c39298
|
|
| MD5 |
6420bb86e0dce5efee2fc64cfb5f7bcd
|
|
| BLAKE2b-256 |
ab5eb31edfd4efa216bf316ef6d69d6d4ceef5ce3d1372a51df87db2aa9c6a57
|
Provenance
The following attestation bundles were made for placeholder-1.6-py3-none-any.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-py3-none-any.whl -
Subject digest:
e1fde902a2ebb02f65c7156e07ff41bb02aee9f7d98482d242963c3514c39298 - Sigstore transparency entry: 2202082693
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 10.1 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
076c9985f3a37e57a7db232b4f33768f73f7f7bbdce915ed51bb0b813aea2dbf
|
|
| MD5 |
08e59143e7f4c0a70e7f5e000669a606
|
|
| BLAKE2b-256 |
a6e0fa9db2de905130edbba78b969bc8667e7c5a971922df56cd2c738439e346
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-win_amd64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-win_amd64.whl -
Subject digest:
076c9985f3a37e57a7db232b4f33768f73f7f7bbdce915ed51bb0b813aea2dbf - Sigstore transparency entry: 2202082206
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-win32.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-win32.whl
- Upload date:
- Size: 9.9 kB
- Tags: CPython 3.11+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
900a89a154110661fca12df0ecfd2b0efdfa47617381b174826b7cc64b1b7360
|
|
| MD5 |
a7c7ac0ca22fd7c755ff366e6e06a2ee
|
|
| BLAKE2b-256 |
57851b0d6ad4627f2401663ceb9fb3b8fa1e178bdf9a5c5cee7443a71c6daf22
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-win32.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-win32.whl -
Subject digest:
900a89a154110661fca12df0ecfd2b0efdfa47617381b174826b7cc64b1b7360 - Sigstore transparency entry: 2202082836
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 10.8 kB
- Tags: CPython 3.11+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c93d3194ae83d2eb870b0cbf646a32c2f62734a78ae173cf4c624fcad6fc0bc3
|
|
| MD5 |
6d9489e2a1b686a62e41a70e06038bf7
|
|
| BLAKE2b-256 |
67eef24dd6f26dfe7f8c9314dfd871445f850ade79d42504b98c22122d8c461b
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
c93d3194ae83d2eb870b0cbf646a32c2f62734a78ae173cf4c624fcad6fc0bc3 - Sigstore transparency entry: 2202082759
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 11.4 kB
- Tags: CPython 3.11+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4634694c8ebde89fb53a99d2734755b90eb683b32aa41a1112166726d45bbf2
|
|
| MD5 |
38e77a84a87a43896ae45531d1a4c34d
|
|
| BLAKE2b-256 |
7e359bdb2a2fc101f07a1ec9e8057d21f6f171b7df024023684280ffb55f1093
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-musllinux_1_2_aarch64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
f4634694c8ebde89fb53a99d2734755b90eb683b32aa41a1112166726d45bbf2 - Sigstore transparency entry: 2202082497
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 11.5 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
204adeeedb887c02006dde74e8548a8d19f69b56cb469c9c22847f8509966f0e
|
|
| MD5 |
4faa8fe1fdc8da818a36b80e71385069
|
|
| BLAKE2b-256 |
23e9111fcf979400bf0c3498a23e8e074192f255ee7be35679400655e5a6af61
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
204adeeedb887c02006dde74e8548a8d19f69b56cb469c9c22847f8509966f0e - Sigstore transparency entry: 2202082635
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 10.5 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55a11a3fa9776138ed962b5636af00ed989c2525c3f1b7d2d1a312a81c255b25
|
|
| MD5 |
7a72b7127c953ad218522caa4f25a036
|
|
| BLAKE2b-256 |
382e9bf7efb644772cbf1b94f575f1311b96d89f8325cdc233d4859b7253f060
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
55a11a3fa9776138ed962b5636af00ed989c2525c3f1b7d2d1a312a81c255b25 - Sigstore transparency entry: 2202082575
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 7.8 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cefc7fe0ccef3d9af1a3fc953be2ed2215d719847570da65c6c89de09c001cf
|
|
| MD5 |
445386f1c370bc08a773a0daf3f27e77
|
|
| BLAKE2b-256 |
9c79ee3aa2b06bba613daffd7bc9147fa15b13c6274761670fd0bcc30c966fd4
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
3cefc7fe0ccef3d9af1a3fc953be2ed2215d719847570da65c6c89de09c001cf - Sigstore transparency entry: 2202082431
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file placeholder-1.6-cp311-abi3-macosx_10_9_x86_64.whl.
File metadata
- Download URL: placeholder-1.6-cp311-abi3-macosx_10_9_x86_64.whl
- Upload date:
- Size: 7.4 kB
- Tags: CPython 3.11+, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f00ba7a2cd71d0bfaee647fe879d531b079a279d38752618d17b72aff8cf28a0
|
|
| MD5 |
e0a711c6f1dbd31821a1dc9e2ece62e2
|
|
| BLAKE2b-256 |
c23a16675bd1a178a4878132a6abececeb28562a30fa0cbbbd85690bce79988a
|
Provenance
The following attestation bundles were made for placeholder-1.6-cp311-abi3-macosx_10_9_x86_64.whl:
Publisher:
release.yml on coady/placeholder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
placeholder-1.6-cp311-abi3-macosx_10_9_x86_64.whl -
Subject digest:
f00ba7a2cd71d0bfaee647fe879d531b079a279d38752618d17b72aff8cf28a0 - Sigstore transparency entry: 2202082312
- Sigstore integration time:
-
Permalink:
coady/placeholder@04c5aa47804943d9a58b47e515127e3bda0750ff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04c5aa47804943d9a58b47e515127e3bda0750ff -
Trigger Event:
workflow_dispatch
-
Statement type: