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

glob returns results in undeterministic order #74646

Closed
bmwiedemann mannequin opened this issue May 24, 2017 · 4 comments
Closed

glob returns results in undeterministic order #74646

bmwiedemann mannequin opened this issue May 24, 2017 · 4 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@bmwiedemann
Copy link
Mannequin

bmwiedemann mannequin commented May 24, 2017

BPO 30461
Nosy @rhettinger, @serhiy-storchaka, @bmwiedemann
PRs
  • bpo-30461: glob: sort the resulting list #1794
  • 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 2017-06-04.17:23:33.500>
    created_at = <Date 2017-05-24.19:29:31.923>
    labels = ['3.7', 'library']
    title = 'glob returns results in undeterministic order'
    updated_at = <Date 2017-06-04.17:23:33.498>
    user = 'https://github.com/bmwiedemann'

    bugs.python.org fields:

    activity = <Date 2017-06-04.17:23:33.498>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-06-04.17:23:33.500>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2017-05-24.19:29:31.923>
    creator = 'bmwiedemann'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30461
    keywords = []
    message_count = 4.0
    messages = ['294381', '294391', '295117', '295133']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'serhiy.storchaka', 'bmwiedemann']
    pr_nums = ['1794']
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue30461'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7']

    @bmwiedemann
    Copy link
    Mannequin Author

    bmwiedemann mannequin commented May 24, 2017

    because POSIX readdir does not guarantee any order
    glob often gives unexpectedly random results.

    Some background:
    for openSUSE Linux we build packages in the Open Build Service (OBS)
    which tracks dependencies, so when e.g. a new glibc is submitted,
    all packages depending on glibc are rebuilt
    and if those depending binaries changed,
    the new version is pushed to the mirrors.

    Many python modules build their .so files from a glob.glob(path, "*.cpp")

    The old glob behaviour would often lead to the linker
    randomly ordering functions in resulting object files,
    thus we were not able to auto-detect
    that the package did not actually change
    which wastes bandwidth of distribution mirrors and users.

    See also https://reproducible-builds.org/ on that topic.

    There are plenty affected packages out there
    https://github.com/pytries/datrie/blob/master/setup.py#L10
    https://github.com/jonashaag/bjoern/blob/master/setup.py#L6
    https://github.com/scipy/scipy/blob/master/scipy/sparse/linalg/dsolve/setup.py#L28

    @bmwiedemann bmwiedemann mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels May 24, 2017
    @serhiy-storchaka
    Copy link
    Member

    This looks as a duplicate of bpo-21748. That behavior was explicitly documented in bpo-25615.

    @bmwiedemann
    Copy link
    Mannequin Author

    bmwiedemann mannequin commented Jun 4, 2017

    From my performance measurements, the overhead was negligible (not even counting the processing done on files returned by glob).

    And also glob in C, bash, perl all do sort by default and these are generally pretty fast languages, yet they still chose consistency over performance.

    I updated my PR to also update the documentation accordingly.

    @bmwiedemann bmwiedemann mannequin reopened this Jun 4, 2017
    @rhettinger
    Copy link
    Contributor

    Sorry, we're going to reject this patch for the reasons discussed in the two other referenced patches.

    If a user wants sorted order, they can effortlessly specify that with sorted(glob('*.cpp')).

    @rhettinger rhettinger removed the invalid label Jun 4, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants