Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize pathlib.Path.iterdir() #90474

Closed
barneygale mannequin opened this issue Jan 9, 2022 · 2 comments
Closed

Optimize pathlib.Path.iterdir() #90474

barneygale mannequin opened this issue Jan 9, 2022 · 2 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir

Comments

@barneygale
Copy link
Mannequin

barneygale mannequin commented Jan 9, 2022

BPO 46316
Nosy @zware, @barneygale
PRs
  • bpo-46316: optimize pathlib.Path.iterdir() #30501
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-01-20.19:20:39.376>
    created_at = <Date 2022-01-09.14:52:52.043>
    labels = ['library', '3.11']
    title = 'Optimize pathlib.Path.iterdir()'
    updated_at = <Date 2022-01-20.19:20:39.376>
    user = 'https://github.com/barneygale'

    bugs.python.org fields:

    activity = <Date 2022-01-20.19:20:39.376>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-01-20.19:20:39.376>
    closer = 'zach.ware'
    components = ['Library (Lib)']
    creation = <Date 2022-01-09.14:52:52.043>
    creator = 'barneygale'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46316
    keywords = ['patch']
    message_count = 2.0
    messages = ['410154', '411042']
    nosy_count = 2.0
    nosy_names = ['zach.ware', 'barneygale']
    pr_nums = ['30501']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46316'
    versions = ['Python 3.11']

    @barneygale
    Copy link
    Mannequin Author

    barneygale mannequin commented Jan 9, 2022

    pathlib.Path.iterdir() contains the following code:

        if name in {'.', '..'}:
            # Yielding a path object for these makes little sense
            continue

    This check is unnecessary as os.listdir() does not return entries for '.' or '..':

        os.listdir(path='.')
            Return a list containing the names of the entries in the
            directory given by path. The list is in arbitrary order, and
            does not include the special entries '.' and '..' even if they
            are present in the directory

    See https://docs.python.org/3/library/os.html#os.listdir

    @barneygale barneygale mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir labels Jan 9, 2022
    @zware
    Copy link
    Member

    zware commented Jan 20, 2022

    New changeset a1c8841 by Barney Gale in branch 'main':
    bpo-46316: optimize pathlib.Path.iterdir() (GH-30501)
    a1c8841

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant