partial.lenses icon indicating copy to clipboard operation
partial.lenses copied to clipboard

Document main performance considerations

Open polytypic opened this issue 7 years ago • 2 comments

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

  • [x] Warn about reconstruction of optics in L.choose
  • [x] Explain that nesting traversals doesn't materialize intermediate collections
  • [ ] Explain use of staging to avoid reconstructing optics
  • [ ] Explain use of L.toFunction to precompute compositions

polytypic avatar May 19 '17 13:05 polytypic

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?

fiatjaf avatar Jun 12 '17 23:06 fiatjaf

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.

polytypic avatar Jun 13 '17 00:06 polytypic