| 418 | |
| 419 | @_numpy_contiguous |
| 420 | def _conv_python_to_numpy(array: npt.ArrayLike) -> np.ndarray: |
| 421 | nparr = toarray(array) |
| 422 | if nparr.dtype.kind == "U": |
| 423 | # from Python 3 loads of common strings are disguised as Unicode |
| 424 | try: |
| 425 | # try to convert to basic 'S' type |
| 426 | return nparr.astype("S") |
| 427 | except UnicodeEncodeError: |
| 428 | pass |
| 429 | # pass on true Unicode arrays downstream in case it can be |
| 430 | # handled in the future |
| 431 | return nparr |
| 432 | |
| 433 | |
| 434 | def _conv_numpy_to_python(array: np.ndarray) -> Any | list[Any]: |