calmm-js / partial.lenses

Partial lenses is a comprehensive, high-performance optics library for JavaScript
MIT License
915 stars 36 forks source link

Document main performance considerations #93

Open polytypic opened 7 years ago

polytypic commented 7 years ago

There should a section in the documentation that explains main performance considerations when using lenses.

fiatjaf commented 7 years ago

It seems to be recreating all objects down to the deeper nested path where a transformation occurs. Is that right? Is that the major source of performance concerns?

polytypic commented 7 years ago

The recreation of objects down to where transformation occurs is intentional as the idea is to treat data structures as immutable and not to mutate any existing objects. So, yes that is right and there are certainly cases where use of immutable data structures can be a performance concern, but that is not the kind of performance consideration that this issue mostly about.

The idea with this issue is to document kinds of performance considerations where one might not realize that a particular way to use this library might lead to poor performance compared to some other way to use this library. There is already a section on performance tips, but it is not complete.