fix: use int64 in rle_encode for Windows + NumPy 2 compat - #25
Merged
Merged
Conversation
On Windows, C `long` is 32-bit while NumPy 2's `np.int_` resolves to 64-bit, causing a buffer dtype mismatch in the Cython typed memoryview. Switch to explicit `int64_t` / `np.int64` so the array and memoryview always match regardless of platform. Regenerate the .c file from Cython. Also bump version to 0.2.2 and add regression tests. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rle_encodedeclaredcdef long[:] countswithdtype=np.int_. On Windows, Clongis 32-bit while NumPy 2'snp.int_is 64-bit — Cython rejects the buffer dtype mismatch at runtime.int64_t(fromlibc.stdint) andnp.int64, which are always 64-bit on all platforms. Regenerated the.cfile from Cython.tests/test_run_length_encoding.pywith regression coverage.Context
This blocks Python 3.13 support in darwin-py#1136 — on Windows + Py 3.13, NumPy 2.x is required, triggering this bug. Once this is released, the skip workaround in darwin-py can be removed.
Test plan
rle_encodeproduces correct counts on a simple masktest_complex_polygonpasses on Windows + 3.13 after upgrading upolygonMade with Cursor