Skip to content

Releasing the GIL during matrix image conversion #6520

@hmaarrfk

Description

@hmaarrfk

I'm wondering how you would prefer to deal with small PRs that release the GIL.

I understand that those can cause a lot of churn due to unintended consequences when considering resource utilization.

What did you do?

I opened a PR without raising a dedicated issue first.
#6418

What did you expect to happen?

Given I had done some research on the history of releasing the GIL during computation, I figured that it was OK to open the pull request first.
I was hoping for some comments or feedback, but I understand that different projects have different expectations on the order that things should happen.

What are your OS, Python and Pillow versions?

  • OS: Linux / Windows / OSX (All really!)
  • Python: 3.9
  • Pillow: 9.2.0

Code like this, will not be able to run in parallel on different threads.

import numpy as np
import PIL

image = np.zeros((1024, 1024, 3), dtype='uint8')
img = PIL.Image.fromarray(image)
matrix = (1, 2, 3, 4, 5, 6, 7, 8, 9)
final_image = np.asarray(
    img.convert(mode='RGB', matrix=matrix)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions