Skip to content

python: remove direct dependency on numpy#1281

Merged
reyammer merged 1 commit intomainfrom
py-numpyless
Feb 13, 2026
Merged

python: remove direct dependency on numpy#1281
reyammer merged 1 commit intomainfrom
py-numpyless

Conversation

@reyammer
Copy link
Collaborator

@reyammer reyammer commented Feb 12, 2026

Fixes #1268.

There don't seem to be performance regressions. The mean inference time and other metrics are relatively noisy, but there doesn't seem to be a big change. Cherrypicked examples below.

Stats with numpy (old version):

Inference stats over 770 files (repeat=10):
  Min: 0.0730 ms
  Max: 12.0421 ms
  Mean: 5.2871 ms
  Median: 5.2845 ms
  Total: 4071.0329 ms

Stats without numpy (this new version):

Inference stats over 770 files (repeat=10):
  Min: 0.0687 ms
  Max: 10.6079 ms
  Mean: 5.2051 ms
  Median: 5.2412 ms
  Total: 4007.9172 ms

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully removes the direct dependency on numpy, which is a great simplification. The changes in pyproject.toml and the removal of numpy imports are correct. The logic to replace numpy functions with pure Python equivalents in magika.py is also sound. I have one suggestion to improve the readability and maintainability of a loop that was refactored.

@reyammer reyammer force-pushed the py-numpyless branch 2 times, most recently from dbc2f19 to 1e755b0 Compare February 12, 2026 14:51
@reyammer reyammer merged commit c707f7f into main Feb 13, 2026
26 checks passed
@reyammer reyammer deleted the py-numpyless branch February 13, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate whether we can get rid of numpy as a dependency in the python package

1 participant