Performance characteristics and design principles
masterPartial Lenses is optimized for high performance with several key design choices:
- Static Land Compliance: Follows the Static Land specification rather than Fantasy Land. This avoids wrapping values in objects (like
Just), reducing memory allocations and overhead. - Direct Optic Values: Allows strings (for properties) and non-negative integers (for indices) to be used directly as optics to avoid unnecessary closure allocations.
- Array Composition: Treats arrays of optics as a composition of optics, allowing for highly efficient path manipulation.
- JSON Focus: Optimized for direct manipulation of JSON-compatible data structures to avoid conversion overhead to specialized immutable collections.
Note on Benchmarks: The library is designed to minimize overhead, avoid stack overflows, and avoid quadratic algorithms. Users should measure their specific use cases, as performance varies by operation type.