Skip to content

b"".join should release GIL in case of memoryview #148323

@googlyrahman

Description

@googlyrahman

Bug report

Bug description:

CPython PR #17757 allowed the GIL to be released during b"".join() operations. However, this optimization currently only triggers if every passed object is of type bytes; it falls back to acquiring the GIL if it encounters mutable buffers. While reacquiring the GIL is necessary for mutable types like bytearray, we can still safely drop the GIL for memoryview objects that expose immutable bytes.

Please refer to fsspec/gcsfs#795 (comment) for more context.

cc: @martindurant

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions