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

copy.copy and copy.deepcopy scale poorly with free-threading #132657

Open
Labels
performancePerformance or resource usagestdlibPython modules in the Lib dirtopic-free-threadingtype-bugAn unexpected behavior, bug, or error
@eendebakpt

Description

@eendebakpt

Thecopy.copy andcopy.deepcopy operations running on different objects in different threads should be able to run independently. The scaling is not good: output of theftscalingbench.py with added benchmarks:

Running benchmarks with 8 threadsshallow_copy               4.6x slowerdeepcopy                   2.3x slowerobject_cfunction           5.9x fastercmodule_function           5.9x fasterobject_lookup_special      5.5x fastermult_constant              5.6x fastergenerator                  4.9x fasterpymethod                   5.2x fasterpyfunction                 4.5x fastermodule_function            5.0x fasterload_string_const          5.6x fasterload_tuple_const           5.9x fastercreate_pyobject            2.3x fastercreate_closure             7.1x fastercreate_dict                3.3x fasterthread_local_read          3.3x faster

There are at least two reasons:

  • Thecopy module uses module level variables in thecopy.copy andcopy.deepcopy methods.
  • The_copy_atomic_types (and some similar data structures) is aset which requires locking for membership testing.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibPython modules in the Lib dirtopic-free-threadingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp