Skip to content

Support FIXEDSTR16 in NumPy imports - #1018

Open
Mango-Clark wants to merge 12 commits into
daphne-project:mainfrom
Mango-Clark:986-python-string-memshare
Open

Support FIXEDSTR16 in NumPy imports#1018
Mango-Clark wants to merge 12 commits into
daphne-project:mainfrom
Mango-Clark:986-python-string-memshare

Conversation

@Mango-Clark

Copy link
Copy Markdown

Refs #986

Supersedes #1008, which was closed to rename the source branch from new-dev to 986-python-string-memshare.

This PR restores the changes from #1008 without changing the original scope.

Refs daphne-project#986

- Fix NumPy shared-memory pointer extraction by moving extracting the raw data address after the dtype normalization and C-contiguity handling. NumPy dtype conversion and contiguous-layout conversion may allocate a new array, so the pointer must be taken only after the final array object is fixed.
- Support FIXEDSTR16 imports for string-like NumPy arrays.
- Values longer than 15 bytes are rejected
- Byte-string dtype ('S') arrays are supported. Arrays with dtype width up to 15 bytes can be converted directly to S16. Wider byte-string arrays are scanned by actual value length before being narrowed to S16.
- Unicode dtype ('U') arrays are encoded as UTF-8 before checking their byte length, since NumPy's Unicode itemsize is based on UTF-32 storage width and does not represent the UTF-8 payload size.
- Object dtype ('O') arrays are supported only for explicit string-like, bytes-like, and common missing values:
	- None as b'None'
	- np.nan as b'np.nan'
	- pd.NA as b'pd.NA'
	- pd.NaT as b'pd.NaT'
	- str
	- np.str_
	- bytes
	- np.bytes_
	- bytearray
	- memoryview
- Arbitrary mixed object values are rejected to avoid silent coercion.
Register FixedStr16 print support and assert received payloads.
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