barneygale / pathlib-abc

Python base classes for rich path objects
Other
23 stars 1 forks source link

`PathBase.resolve()` is too slow #15

Closed barneygale closed 6 months ago

barneygale commented 6 months ago

The current implementation of this method can generate huge numbers of path objects, which is very slow.

It should be possible to rewrite it as in-place: manipulate _raw_paths as we go, rather than spinning up new path objects all the time. To do this we probably need to eliminate some caching - see #10

barneygale commented 6 months ago

Should be much improved in 0.2.0. There's a further possible optimization which involves repeatedly modifying the _raw_path of a single path object, but it breaks pathlib's rules about immutability in a way that would be visible in user implementations of stat() and readlink(), and so we'd need to make _resolving public to clue users into whether caching is appropriate/etc. It's all pretty complicated and probably not worth it, so I'll consider this issue resolved until someone complains.