{"id":16802952,"url":"https://github.com/coady/placeholder","last_synced_at":"2025-04-23T04:26:33.156Z","repository":{"id":7492711,"uuid":"42792558","full_name":"coady/placeholder","owner":"coady","description":"Operator overloading for fast anonymous functions.","archived":false,"fork":false,"pushed_at":"2024-09-28T05:49:03.000Z","size":794,"stargazers_count":50,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-14T09:41:34.139Z","etag":null,"topics":["functional","lambda","partial","underscore"],"latest_commit_sha":null,"homepage":"https://coady.github.io/placeholder","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coady.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2015-09-19T22:56:35.000Z","updated_at":"2024-09-29T03:33:00.000Z","dependencies_parsed_at":"2023-11-10T18:28:09.531Z","dependency_job_id":"6d42ed47-b976-469e-ba5d-be796ad64dc1","html_url":"https://github.com/coady/placeholder","commit_stats":{"total_commits":112,"total_committers":3,"mean_commits":"37.333333333333336","dds":0.3392857142857143,"last_synced_commit":"9a706b15b34d511e5202039abf1b183df425fcbf"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fplaceholder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fplaceholder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fplaceholder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fplaceholder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coady","download_url":"https://codeload.github.com/coady/placeholder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250369053,"owners_count":21419177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["functional","lambda","partial","underscore"],"created_at":"2024-10-13T09:41:08.955Z","updated_at":"2025-04-23T04:26:33.132Z","avatar_url":"https://github.com/coady.png","language":"Python","readme":"[![image](https://img.shields.io/pypi/v/placeholder.svg)](https://pypi.org/project/placeholder/)\n![image](https://img.shields.io/pypi/pyversions/placeholder.svg)\n[![image](https://pepy.tech/badge/placeholder)](https://pepy.tech/project/placeholder)\n![image](https://img.shields.io/pypi/status/placeholder.svg)\n[![build](https://github.com/coady/placeholder/actions/workflows/build.yml/badge.svg)](https://github.com/coady/placeholder/actions/workflows/build.yml)\n[![image](https://codecov.io/gh/coady/placeholder/branch/main/graph/badge.svg)](https://codecov.io/gh/coady/placeholder/)\n[![CodeQL](https://github.com/coady/placeholder/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/coady/placeholder/actions/workflows/github-code-scanning/codeql)\n[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/coady/placeholder)\n[![image](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![image](https://mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n\nA `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, and resembles Scala's placeholders.\n\n## Usage\n```python\nfrom placeholder import _     # single underscore\n\n_.age \u003c 18     # lambda obj: obj.age \u003c 18\n_[key] ** 2    # lambda obj: obj[key] ** 2\n```\n\nNote `_` has special meaning in other contexts, such as the previous output in interactive shells. Assign to a different name as needed. Kotlin uses `it`, but in Python `it` is a common short name for an iterator.\n\n`_` is a singleton of an `F` class, and `F` expressions can also be used with functions.\n\n```python\nfrom placeholder import F\n\n-F(len)        # lambda obj: -len(obj)\n```\n\nAll applicable double underscore methods are supported.\n\n## Performance\nEvery effort is made to optimize the placeholder instance. It's 20-40x faster than similar libraries on PyPI.\n\nPlaceholders are also iterable, allowing direct access to the underlying functions.\n\n```python\n(func,) = _.age  # operator.attrgetter('age')\n```\n\nPerformance should generally be comparable to inlined expressions, and faster than lambda. Below are some example benchmarks.\n\n```python\nmin(data, key=operator.itemgetter(-1))    # 1x\nmin(data, key=_[-1])                      # 1.3x\nmin(data, key=lambda x: x[-1])            # 1.6x\n```\n\n## Installation\n```console\n% pip install placeholder\n```\n\n## Tests\n100% branch coverage.\n\n```console\n% pytest [--cov]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoady%2Fplaceholder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoady%2Fplaceholder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoady%2Fplaceholder/lists"}