FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve the performance of ntpath.expanduser() · Issue #117686 · python/cpython · GitHub

Repository navigation

Improve the performance of ntpath.expanduser() #117686

Closed

Description

Feature or enhancement

Proposal:

In ntpath.expanduser(), _get_bothseps() is called in every loop iteration. It should be assigned instead:

 if isinstance(path, bytes):
+    seps = b'\\/'
     tilde = b'~'
 else:
+    seps = '\\/'
     tilde = '~'
 if not path.startswith(tilde):
     return path
 i, n = 1, len(path)
-while i < n and path[i] not in _get_bothseps(path):
+while i < n and path[i] not in seps:
     i += 1

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

Linked PRs

Activity

  1. changed the title [-]Move `_get_bothseps()` outside loop condition[/-] [+]Improve the performance of ntpath.expanduser()[/+] on Apr 9, 2024
  2. terryjreedy commented on Apr 10, 2024

    Member

    To me, this is a clearly better.

  3. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Apr 10, 2024
  4. added a commit that references this issue on Apr 10, 2024
  5. erlend-aasland commented on Apr 10, 2024

    Contributor

    Thanks!

  6. added a commit that references this issue on Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL