lenses
A lens library for python
Decision gist · record as of 2026-08-14
Yes, if you work regularly with nested data structures and want cleaner, more composable transformation code. The copyleft GPLv3+ license is a hard blocker for proprietary projects. The dormant maintenance status is a minor concern—the library is stable and has no known vulnerabilities, but you should verify that its behavior matches your needs before adopting it for new projects.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or later (supports up to 3.11).
- Installation is straightforward with no runtime dependencies.
- The package is in production/stable status but dormant—last release was over a year ago, though the repository remains active and supported on Python 3.7 through 3.11.
License · maintenance · safety
GPLv3+ (copyleft) — Licensed under GPLv3+, a copyleft license. Any derivative work or distribution must also be open-source under compatible terms; this is a significant constraint for proprietary or closed-source projects.
last release 2023-10-24 (1025 days) · last repo commit 2023-11-15 · 339 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 163,389 downloads/mo, #10,571 on PyPI
Alternatives
Verify before relying
pip install lenses
from lenses import lens
data = [{'name': 'Jane', 'scores': ['a', 'b']}, {'name': 'Zoe', 'scores': ['f', 'f']}]
format_scores = lens.Each()['scores'].Each().Instance(str).call_upper()
result = format_scores(data)- Whether the dormant maintenance status affects real-world usability or indicates unaddressed issues.
- Performance characteristics on very large or deeply nested data structures compared to imperative approaches.
What it is and what it does
Lenses is a Python library that implements functional lens patterns to safely navigate and transform nested data structures without mutating the original. It lets you compose operations like filtering, mapping, and method calls across arbitrary levels of nesting—lists, dicts, custom objects—in a single declarative expression. Instead of writing nested loops and conditionals to reach deep values and rebuild structures, you chain lens operations that describe the path and transformation, then apply them to your data.
The library is inspired by Haskell's lens ecosystem but adapted for Python's imperative style. It has no external runtime dependencies and works across modern Python versions (3.7–3.11). The main trade-off is that the lens syntax is unfamiliar to most Python developers and requires learning a new mental model; the payoff is cleaner, more composable code for complex data transformations that would otherwise require deeply nested loops.
Use it for
- Transform deeply nested JSON or dictionary structures (e.g., API responses) without writing nested loops.
- Apply the same operation to all matching elements across multiple levels of nesting in a single expression.
- Build reusable, composable data transformations that can be combined and tested independently.
- Work with immutable data patterns in functional Python code or when mutation safety is required.
- Extract and modify specific fields in complex object hierarchies without intermediate variable assignments.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you work regularly with nested data structures and want cleaner, more composable transformation code.
The copyleft GPLv3+ license is a hard blocker for proprietary projects. The dormant maintenance status is a minor concern—the library is stable and has no known vulnerabilities, but you should verify that its behavior matches your needs before adopting it for new projects.
Install
lenses on PyPI
Before you install
Installation is straightforward with no runtime dependencies. The package is in production/stable status but dormant—last release was over a year ago, though the repository remains active and supported on Python 3.7 through 3.11.
Requires Python 3.7 or later (supports up to 3.11).
License in practice
Licensed under GPLv3+, a copyleft license. Any derivative work or distribution must also be open-source under compatible terms; this is a significant constraint for proprietary or closed-source projects.
Quickstart
pip install lenses
from lenses import lens
data = [{'name': 'Jane', 'scores': ['a', 'b']}, {'name': 'Zoe', 'scores': ['f', 'f']}]
format_scores = lens.Each()['scores'].Each().Instance(str).call_upper()
result = format_scores(data)
Verify before relying
- Whether the dormant maintenance status affects real-world usability or indicates unaddressed issues.
- Performance characteristics on very large or deeply nested data structures compared to imperative approaches.
Package facts
| License | GPLv3+ copyleft |
| Python support | Supports the current Python release >=3.7, <4 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Dormant 1,025 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 163,389 / month, #10,571 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)Natural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries |
Evidence: lenses-1.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “immutable data structure manipulation”
- lensesLenses provides a functional approach to reading and modifying nested…
- purlProvides an immutable, chainable URL class for constructing, parsing,…
- immutabledictProvides an immutable dictionary wrapper that implements the complete…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also oslash · immutables · returns · itypes · purify · Expression · deepdiff6 · funcy · sae-lens · pyrsistent