Skip to content

Update to Python 3.15, other maintenance, and allocator stuff - #157

Open
eriknw wants to merge 2 commits into
GraphBLAS:mainfrom
eriknw:3.15
Open

eriknw wants to merge 2 commits into
GraphBLAS:mainfrom
eriknw:3.15

Conversation

@eriknw

@eriknw eriknw commented Oct 6, 2026

Copy link
Copy Markdown
Member

No description provided.

eriknw added 2 commits October 4, 2026 22:39
NumPy 2.5 allocates with PyMem_RawMalloc, but frees OWNDATA arrays that
have no memory handler with libc free(). The two differ on free-threaded
3.15 (mimalloc) and under PYTHONMALLOC=debug, so matrix.serialize and
binread aborted there.

- claim_buffer attaches NumPy's default memory handler (setup.py sets
  NPY_TARGET_VERSION to 1.22 to expose it)
- binread allocates with GraphBLAS's own allocator instead of libc malloc
- add utils.can_unclaim_buffer to check before handing an array's buffer
  to GraphBLAS; document unclaim_buffer
- initialize() raises if GraphBLAS fails to initialize
- add tests/test_memory.py (runs in a subprocess with PYTHONMALLOC=debug)

Python 3.15 and maintenance:
- add 3.15 classifier and Black target; test 3.15 rc in CI via the
  conda-forge python_rc channel, ranked below conda-forge
- cibuildwheel v3.4 -> v4.2 (builds cp315 and cp315t wheels)
- update all actions and pin them to commit SHAs; group Dependabot
  updates with a 7-day cooldown
- least-privilege workflow permissions, cancel superseded PR runs, no
  ${{ }} expansion inside run: scripts; `bash -el` so a failing command
  in a multi-command test step fails the step
- stricter pytest config: warnings are errors, strict markers and config
- update pre-commit hooks; add actionlint, zizmor and pysentry
- rename CLAUDE.md to AGENTS.md and update it
- publish via PyPI Trusted Publishing (environments pypi and test-pypi)
  instead of an API token
GraphBLAS (>= 10.4) frees a buffer with its arena's allocator, and NumPy
frees an array's data with the array's memory handler. A buffer that
crosses between them needs both to agree, or the wrong free aborts
(free-threaded 3.15, PYTHONMALLOC=debug) or corrupts memory.

- claim_buffer and claim_buffer_2d attach the handler for the buffer's
  arena (NumPy's default if the arena uses NumPy's allocator, else one
  that calls the arena's functions); new optional `arena` argument
- add give_buffer, a context manager that hands an array (or a copy)
  to GraphBLAS and commits only if GraphBLAS took it, and empty(),
  which allocates arrays GraphBLAS can always own
- can_unclaim_buffer checks the handler matches the arena;
  unclaim_buffer raises if the array can't be owned
- serialize_* name the result's arena; binread reads into the new
  matrix's arena and packs with give_buffer, which also fixes iso
  matrices packed with a full-size Ax_size; binwrite restores the
  matrix if writing fails
- tests fail when NumPy frees an array that has no handler; test_memory
  covers both memory managers and a libc arena (explicit, global, and
  Context); doctests run for every api module; wheel tests use -W error
- drop stale flake8 ignores; ignore create_headers.py's output

This branch has not been deployed

No deployments
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.

1 participant