Skip to content

Stop manually interning strings in pathlib #119518

Closed
@barneygale

Description

@barneygale

When parsing and normalizing a path, pathlib calls sys.intern() on the string parts:

parsed = [sys.intern(str(x)) for x in rel.split(sep) if x and x != '.']

I've never been able to establish that this is a worthwhile thing to do. The implementation seems incomplete, because the path normalization only occurs when a user manually initialises a path object, and not in paths generated from path.iterdir(), path.walk(), etc. Drives/roots/anchors aren't interned despite most likely to be shared.

Previous discussion: #112856 (comment)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions