File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,15 @@ impl PyArrayDescr {
368
368
/// Currently, only integer/float/complex/object types are supported. The [NumPy documentation][enumerated-types]
369
369
/// list the other built-in types which we are not yet implemented.
370
370
///
371
+ /// Note that NumPy's integer types like `numpy.int_` and `numpy.uint` are based on C's integer hierarchy
372
+ /// which implies that their widths change depending on the platform's [data model][data-models].
373
+ /// For example, `numpy.int_` matches C's `long` which is 32 bits wide on Windows (using the LLP64 data model)
374
+ /// but 64 bits wide on Linux (using the LP64 data model).
375
+ ///
376
+ /// In contrast, Rust's [`isize`] and [`usize`] types are defined to have the same width as a pointer
377
+ /// and are therefore always 64 bits wide on 64-bit platforms. If you want to match NumPy's behaviour,
378
+ /// consider using the [`c_long`][std::ffi::c_long] and [`c_ulong`][std::ffi::c_ulong] type aliases.
379
+ ///
371
380
/// # Safety
372
381
///
373
382
/// A type `T` that implements this trait should be safe when managed by a NumPy
@@ -390,6 +399,7 @@ impl PyArrayDescr {
390
399
/// safely and efficiently using [`from_owned_object_array`][crate::PyArray::from_owned_object_array].
391
400
///
392
401
/// [enumerated-types]: https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types
402
+ /// [data-models]: https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
393
403
pub unsafe trait Element : Clone + Send {
394
404
/// Flag that indicates whether this type is trivially copyable.
395
405
///
You can’t perform that action at this time.
0 commit comments