Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimize pathlib path pickling #112855

Closed
Closed
@barneygale

Description

@barneygale

pathlib.PurePath.__reduce__() currently accesses and returnstheparts tuple. Pathlib ensures that the strings therein areinterned.

There's a good reason to do this: it ensures that the pickled data is as small as possible, with maximum re-use of small string objects.

However, it comes with some disadvantages:

  1. When normalising any path, we need to callsys.intern(str(part)) on each part
  2. When pickling a path, we must join, parse and normalise, and then generate theparts tuple.

We could instead make__reduce__() return the raw paths fed to the constructor (the_raw_paths attribute). This would be faster but less space efficient. With the cost of storage and bandwidth falling at a faster rate than compute, I suspect this trade-off is worth making.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp