Skip to content

Deoptimise pathlib ABCs #113528

Closed
Closed
@barneygale

Description

@barneygale

Feature or enhancement

pathlib._abc.PurePathBase and PathBase have a few slots and methods that facilitate fast path object generation:

  • _drv, _root, _tail_cached: roughly, the result of os.path.splitroot() on the path
  • _str: the normalized path string
  • _make_child_relpath(): used when walking directories
  • _from_parsed_parts(): used in parent, parents, with_name(), relative_to()

These carefully-tuned features are useful in pathlib, where speed is important, but much less so in pathlib._abc, where the clarity of the interfaces and interactions should win out.

It should be possible to move them to PurePath, leaving PurePathBase with only _raw_paths and _resolving slots.

This should not affect the behaviour or performance of the public classes in pathlib proper.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions