René's URL Explorer Experiment


Title: RFC: Array Reference Type · Issue #879 · rust-ndarray/ndarray · GitHub

Open Graph Title: RFC: Array Reference Type · Issue #879 · rust-ndarray/ndarray

X Title: RFC: Array Reference Type · Issue #879 · rust-ndarray/ndarray

Description: Please post your thoughts, or let me know if something is unclear/confusing! Summary This RFC proposes the addition of a new storage type RefRepr and associated type aliases ArrayRef, ArrayRef1, ArrayRef2, etc., such that we ...

Open Graph Description: Please post your thoughts, or let me know if something is unclear/confusing! Summary This RFC proposes the addition of a new storage type RefRepr and associated type aliases ArrayRef, ArrayRe...

X Description: Please post your thoughts, or let me know if something is unclear/confusing! Summary This RFC proposes the addition of a new storage type RefRepr and associated type aliases ArrayRef<A, D>, A...

Opengraph URL: https://github.com/rust-ndarray/ndarray/issues/879

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RFC: Array Reference Type","articleBody":"Please post your thoughts, or let me know if something is unclear/confusing!\r\n\r\n# Summary\r\n\r\nThis RFC proposes the addition of a new storage type `RefRepr` and associated type aliases `ArrayRef\u003cA, D>`, `ArrayRef1\u003cA>`, `ArrayRef2\u003cA>`, etc., such that we can implement the following traits:\r\n\r\n- `Borrow\u003cArrayRef\u003cA, D>>` for `ArrayBase\u003cS, D> where S: Data`\r\n- `Deref\u003cTarget = ArrayRef\u003cA, D>>` for `ArrayBase\u003cS, D> where S: Data`\r\n- `BorrowMut\u003cArrayRef\u003cA, D>>` for `ArrayBase\u003cS, D> where S: DataMut`\r\n- `DerefMut\u003cTarget = ArrayRef\u003cA, D>>` for `ArrayBase\u003cS, D> where S: DataMut`\r\n- `ToOwned\u003cOwned = Array\u003cA, D>>` for `ArrayRef\u003cA, D>`\r\n\r\n`&'a ArrayRef\u003cA, D>` would be analogous to `ArrayView\u003c'a, A, D>`, and `&'a mut ArrayRef\u003cA, D>` would be analogous to `ArrayViewMut\u003c'a, A, D>`.\r\n\r\nMany of the methods on `ArrayBase` would be moved to be implemented only on `ArrayRef` instead, and be available through deref coercion, similar to how much of the functionality of `Vec\u003cT>` is actually implemented on `[T]`.\r\n\r\n# Motivation\r\n\r\n## Good way to express function parameters\r\n\r\nConsider a function that needs a view of a 2-D array of `f64` elements. With current `ndarray`, we have the following ways to express this:\r\n\r\n```rust\r\n// Option 1\r\nfn function\u003cS>(arr: &ArrayBase\u003cS, Ix2>)\r\nwhere\r\n    S: Data\u003cElem = f64>,\r\n{}\r\n\r\n// Option 2\r\nfn function\u003c'a, V: AsArray\u003c'a, f64, Ix2>>(arr: V) {}\r\n\r\n// Option 3\r\nfn function\u003c'a>(arr: impl AsArray\u003c'a, f64, Ix2>) {}\r\n\r\n// Option 4\r\nfn function(arr: ArrayView2\u003c'_, f64>) {}\r\n```\r\n\r\nEach of these has disadvantages:\r\n\r\n- Options 1 and 2 are verbose, and become particularly bad for functions taking many array parameters.\r\n\r\n- Option 4 is unnatural for callers of the function. (In most cases, they have to call `.view()` on the argument, which is verbose and is different from most Rust code, which typically uses references for this use-case.)\r\n\r\n- Options 1, 2, and 3 are generic, so they suffer from monomorphization bloat, as discussed in the next section. For functions taking multiple array parameters, it's even worse—the number of possible type combinations is exponential in the number of array parameters. (To minimize the bloat, it's necessary to create an inner function like option 4, and make the outer function convert the parameter(s) to `ArrayView` and call the inner function.)\r\n\r\nWith this RFC, it will be possible to express the function like this:\r\n\r\n```rust\r\nfn function(arr: &ArrayRef2\u003cf64>) {}\r\n```\r\n\r\nThis is more concise than the other options, and it's not generic, so there is no monomorphization bloat.\r\n\r\nMutable views would be handled similarly, just with `&mut` instead of `&`.\r\n\r\n## Substantially reduce monomorphization bloat\r\n\r\nMost of the functionality of `ndarray` is currently implemented as methods on `ArrayBase\u003cS, D>`. As a result, the methods are monomorphized for each new combination of `S` and `D` types, which means that there's a lot of nearly-identical generated code, i.e. \"monomorphization bloat\". The same issue occurs for crates which provide extension traits, such as `ndarray-linalg`, `ndarray-stats`, and `ndarray-npy`. (It's possible to minimize monomorphization bloat for a method by changing it to convert everything to `ArrayView/Mut` and then call an inner function which takes `ArrayView/Mut` parameters. However, that's very verbose and tedious.)\r\n\r\nIf, instead, we move most functionality to be implemented only on `ArrayRef\u003cA, D>`, analogous to how much of the functionality of `Vec\u003cT>` is actually implemented on `[T]`, then the monomorphization bloat due to differing storage types would be eliminated. (Callers would rely on deref coercion, like they do for methods actually implemented on `[T]` for `Vec\u003cT>`.)\r\n\r\n## Enable in-place arithmetic operator syntax for the result of a slicing operation\r\n\r\nCurrently, it's not possible to use in-place arithmetic operator syntax for the results of slicing operations; instead, it's necessary to call the appropriate method:\r\n\r\n```rust\r\nlet mut a = array![0, 1, 2, 3, 4];\r\n\r\n// Compiles:\r\nuse std::ops::AddAssign;\r\na.slice_mut(s![1..3]).add_assign(1);\r\n\r\n// Doesn't compile:\r\n*a.slice_mut(s![1..3]) += 1;\r\n```\r\n\r\nThe error message is\r\n\r\n```\r\nerror[E0614]: type `ArrayBase\u003cViewRepr\u003c&mut {integer}>, Dim\u003c[usize; 1]>>` cannot be dereferenced\r\n  --> src/main.rs:11:5\r\n   |\r\n11 |     *a.slice_mut(s![1..3]) += 1;\r\n   |    \r\n```\r\n\r\nBy making `ArrayBase` dereference to `ArrayRef` and implementing the in-place arithmetic operators on `ArrayRef`, this will compile without errors.\r\n\r\n## Better integration into the Rust ecosystem\r\n\r\nThe existing Rust ecosystem provides functionality dependent on traits like `Borrow`. Implementing these traits will allow `ndarray` to interact more cleanly with the rest of the ecosystem. See #878 for one example.\r\n\r\n# Guide-level explanation\r\n\r\nIn many ways, an owned array `Array\u003cA, D>` is similar to `Vec\u003cA>`. It is an allocated container for a collection of elements.\r\n\r\nThe new `ArrayRef\u003cA, D>` type for arrays is analogous to the `[A]` (i.e. slice) type for vectors. Arrays dereference to `ArrayRef\u003cA, D>`, like `Vec\u003cA>` derefs to `[A]`, so functionality available for `ArrayRef\u003cA, D>` is available for other array types through deref coercion, like how functionality available for `[A]` is available for `Vec\u003cA>` through deref coercion.\r\n\r\nWhen writing a function, you should use `&ArrayRef\u003cA, D>` or `&mut ArrayRef\u003cA, D>` as the parameter types when possible, similar to how you'd use `&[A]` or `&mut [A]` instead of `&Vec\u003cA>` or `&mut Vec\u003cA>`.\r\n\r\nIn general, handle `ArrayRef\u003cA, D>` analogously to how you'd handle `[A]`. The primary ways in which they are not analogous are the following:\r\n\r\n- `ArrayRef\u003cA, D>` is `Sized`, unlike `[A]`. As a result, `&ArrayRef\u003cA, D>` is a thin pointer, while `&[A]` is a thick pointer.\r\n\r\n- Due to technical limitations, given an array it's not possible to *directly* create an `&ArrayRef` that is a view of a portion of the array. In other words, you can create a slice (i.e. `&[A]`) of a portion of a `&[A]`/`Vec\u003cA>` with indexing, e.g. `&var[3..12]`, but this is not possible for `&ArrayRef`. In order to create an `&ArrayRef` that references a portion of an array, you have to first create an `ArrayView` (by slicing, etc.), and then coerce that `ArrayView` to `ArrayRef`.\r\n\r\nAlso note that `&'a ArrayRef\u003cA, D>` is similar to `ArrayView\u003c'a, A, D>`, and `&'a mut ArrayRef\u003cA, D>` is similar to `ArrayViewMut\u003c'a, A, D>`, with the following exceptions:\r\n\r\n- You don't have call a method like `.reborrow()` (for `ArrayView/Mut`) to manually shorten the lifetime of the borrow. The lifetimes of references to `ArrayRef` will be automatically adjusted as necessary, just like other references in Rust.\r\n\r\n- The shape, strides, and pointer of an `&ArrayRef\u003cA, D>` or `&mut ArrayRef\u003cA, D>` cannot be modified. For example, you can't call `.slice_axis_inplace()`. To get an array with different shape/strides/pointer, you have to create a view. For example, you could call `.slice_axis()`, or you could create a view with `.view()` and then call `.slice_axis_inplace()` on the view.\r\n\r\n# Implementation\r\n\r\n## Implementing `Deref` and `DerefMut` with `Target = ArrayRef\u003cA, D>`\r\n\r\nThe new `RefRepr` storage type will be:\r\n\r\n```rust\r\n#[repr(C)]\r\npub struct RefRepr\u003cA> {\r\n    elem: PhantomData\u003cA>,\r\n}\r\n```\r\n\r\nThe `ArrayBase` struct will be changed to the following:\r\n\r\n```rust\r\n#[repr(C)]\r\npub struct ArrayBase\u003cS, D>\r\nwhere\r\n    S: RawData,\r\n{\r\n    dim: D,\r\n    strides: D,\r\n    ptr: NonNull\u003cS::Elem>,\r\n    data: S,\r\n}\r\n```\r\n\r\nThe important parts of this change are:\r\n\r\n- The `dim`, `strides`, and `ptr` fields are the first fields in the struct.\r\n\r\n- The struct is declared `repr(C)`.\r\n\r\nThese changes are necessary so that it's possible to implement `Deref` and `DerefMut` by casting references to `ArrayBase` into references to `ArrayRef`.\r\n\r\n@bluss pointed out below that it's necessary to avoid infinite recursion in deref coercion. To do this, a `DataDeref` trait will be added:\r\n\r\n```rust\r\npub unsafe trait DataDeref: Data {}\r\n```\r\n\r\nThis trait will be implemented by all storage types except for `RefRepr` and will be used as a bound for the `Deref` and `DerefMut` implementations.\r\n\r\n`Deref` and `DerefMut` will be implemented like this:\r\n\r\n```rust\r\nimpl\u003cA, S, D> Deref for ArrayBase\u003cS, D>\r\nwhere\r\n    S: Data\u003cElem = A> + DataDeref,\r\n{\r\n    type Target = ArrayRef\u003cA, D>;\r\n\r\n    fn deref(&self) -> &ArrayRef\u003cA, D> {\r\n        unsafe {\r\n            &*(self as *const Self).cast::\u003cArrayRef\u003cA, D>>()\r\n        }\r\n    }\r\n}\r\n\r\nimpl\u003cA, S, D> DerefMut for ArrayBase\u003cS, D>\r\nwhere\r\n    S: DataMut\u003cElem = A> + DataDeref,\r\n{\r\n    fn deref_mut(&mut self) -> &mut ArrayRef\u003cA, D> {\r\n        self.ensure_unique();\r\n        unsafe {\r\n            &mut *(self as *mut Self).cast::\u003cArrayRef\u003cA, D>>()\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n## Moving most existing methods to be implemented only for `ArrayRef\u003cA, D>`\r\n\r\nMost of the existing methods which don't modify the shape/strides/pointer (such as `slice`, `mapv`, etc.) will no longer be implemented for all `ArrayBase\u003cS, D>`, but rather will be implemented only on `ArrayRef\u003cA, D>`. This change isn't necessary in order to introduce the `ArrayRef` type, but it is necessary in order to reduce the existing monomorphization bloat, which is one of the primary benefits of the `ArrayRef` type.\r\n\r\n## Data traits for `RefRepr`\r\n\r\nThe `RefRepr` type will implement the following traits:\r\n\r\n- `RawData`\r\n- `RawDataMut`\r\n- `Data` (but make the `into_owned` implementation panic with `unreachable!()`)\r\n- `DataMut`\r\n- `RawDataSubs`\r\n\r\nIn other words, the `&'a` or `&'a mut` in a reference to an `ArrayRef` will control the lifetime and mutability of the data.\r\n\r\nWe need to audit all of the available methods to make sure that:\r\n\r\n- it's possible to create an `&'a ArrayRef\u003cA, D>` only for a base array with `S: Data` that lives at least as long as `'a`,\r\n- it's possible to create an `&'a mut ArrayRef\u003cA, D>` only for a base array with `S: DataMut` that lives at least as long as `'a`, and\r\n- it's not possible to create an `ArrayRef\u003cA, D>`\r\n\r\n(I believe this is already true if we just add the `Deref`, `DerefMut`, `Borrow`, and `BorrowMut` implementations, but we should check.)\r\n\r\n## Preventing modification of shape/strides/pointer via `&mut ArrayRef\u003cA, D>`\r\n\r\nTo minimize confusion and behave analogously to `&mut [A]`, it should not be possible to modify the underlying shape/strides/pointer through a `&mut ArrayRef\u003cA, D>`. For example,\r\n\r\n```rust\r\nlet mut owned: Array2\u003cf32> = Array::\u003cf32>::zeros((4, 5));\r\nlet mut borrowed: &mut ArrayRef\u003cA, D> = &mut owned;\r\n// should not compile since it would modify the shape/strides/pointer:\r\nborrowed.slice_axis_inplace(Axis(0), ..);\r\n```\r\n\r\nTo achieve this:\r\n\r\n- A new `MetaMut` trait will be added to control whether the shape/strides/pointer can be modified.\r\n\r\n- `MetaMut` will be implemented for all of the existing storage types (`OwnedRepr`, `ViewRepr`, etc.), but not the new `RefRepr` type.\r\n\r\n- A `S: MetaMut` bound will be added to all methods which modify the shape/strides/pointer in-place (such as `slice_collapse`, `slice_axis_inplace`, `collapse_axis`, `swap_axes`, `invert_axis`, `merge_axes`, `insert_axis_inplace`, and `index_axis_inplace`) .\r\n\r\n# Drawbacks\r\n\r\nThis proposal introduces yet another storage type, when `ndarray` already has quite a few.\r\n\r\nThe similarity of `&'a ArrayRef\u003cA, D>` to `ArrayView\u003c'a, A, D>` and `&'a mut ArrayRef\u003cA, D>` to `ArrayViewMut\u003c'a, A, D>` could be confusing to new users.\r\n\r\nThe requirement that it must be possible to create `ArrayRef` references by reinterpreting the bits in existing `ArrayBase` instances limits the possible field layouts of `ArrayBase`.\r\n\r\n# Rationale and alternatives\r\n\r\n## Allow mutation of the shape/strides/pointer for `&mut ArrayRef\u003cA, D>`\r\n\r\nIt would be possible to avoid the new `MetaMut` trait by allowing modification of the shape/strides/pointer through `&mut ArrayRef\u003cA, D>` instances. However, this would likely be confusing to users who are familiar with how `&mut [T]`/`Vec\u003cT>` behave, and it would increase the potential for bugs.\r\n\r\n## Keep most method implementations on all `ArrayBase\u003cS, D>`\r\n\r\nIt would be possible to keep the existing method implementations for all `ArrayBase\u003cS, D>` instead of moving them to be implemented only on `ArrayRef\u003cA, D>`. However, this would not bring the reduced monomorphization bloat which is one of the advantages of the new `ArrayRef` type.\r\n\r\n## Make `ArrayRef` be a separate struct from `ArrayBase`\r\n\r\nIt would be possible for `ArrayRef` to be a separate struct from `ArrayBase`, instead of an alias of `ArrayBase`. This would have the following advantages:\r\n\r\n- `Deref`, `DerefMut`, `Borrow`, and `BorrowMut` could be implemented for `ArrayBase` without `unsafe` code.\r\n- The `MetaMut` and `DataDeref` traits wouldn't be necessary.\r\n- There's less potential for unwanted overlapping or recursive trait impls.\r\n- Keeping the types separate may be less confusing for new users.\r\n\r\nThe disadvantages of a separate struct type are:\r\n\r\n- The transition to `ArrayRef` would be more disruptive. Until libraries update their functions to take `&ArrayRef` or `&mut ArrayRef` parameters instead of `&ArrayBase` or `&mut ArrayBase` parameters, `ArrayRef` would not be compatible with those functions. (Users of those libraries would likely have to call `.view()`/`.view_mut()` in some places.)\r\n\r\n- It may be less convenient for generic code which wants to operate on all array types.\r\n  \r\n  For example, if `ArrayRef` is *not* a separate struct, then these impls are sufficient for `AddAssign`:\r\n\r\n  ```rust\r\n  impl\u003c'b, A, B, S2, D1, D2> AddAssign\u003c&'b ArrayBase\u003cS2, D2>> for ArrayRef\u003cA, D1>\r\n  where\r\n      A: AddAssign\u003c&'b B>,\r\n      B: 'b,\r\n      S2: Data\u003cElem = B>,\r\n      D1: Dimension,\r\n      D2: Dimension,\r\n  {}\r\n\r\n  impl\u003cA, B, D> AddAssign\u003cB> for ArrayRef\u003cA, D>\r\n  where\r\n      A: AddAssign\u003cB>,\r\n      B: ScalarOperand,\r\n      D: Dimension,\r\n  {}\r\n  ```\r\n\r\n  (Note that, unfortunately, we can't replace `impl\u003c'b, A, B, S2, D1, D2> AddAssign\u003c&'b ArrayBase\u003cS2, D2>> for ArrayRef\u003cA, D1>` with `impl\u003c'b, A, B, D1, D2> AddAssign\u003c&'b ArrayRef\u003cB, D2>> for ArrayRef\u003cA, D1>`. For some reason, the compiler has trouble figuring out which impl to use when `impl\u003cA, B, D> AddAssign\u003cB> for ArrayRef\u003cA, D>` also exists.)\r\n\r\n  However, if `ArrayRef` is a separate struct, then it would be necessary to add another impl:\r\n\r\n  ```rust\r\n  impl\u003c'b, A, B, D1, D2> AddAssign\u003c&'b ArrayRef\u003cB, D2>> for ArrayRef\u003cA, D1>\r\n  where\r\n      A: AddAssign\u003c&'b B>,\r\n      B: 'b,\r\n      D1: Dimension,\r\n      D2: Dimension,\r\n  {}\r\n  ```\r\n\r\n## Custom DST (i.e. custom thick pointer types)\r\n\r\nInstead of using thin pointers to `ArrayRef`, we could wait for custom DSTs (e.g. [RFC 2594](https://github.com/rust-lang/rfcs/pull/2594)) to be added to Rust, and then create a custom DST similar to `ArrayRef`. This would have the following advantages:\r\n\r\n- Since the shape/strides/pointer would be stored within the thick pointer, it would be possible to modify the shape/strides/pointer in the thick pointer in-place, unlike for a reference to an `ArrayRef`.\r\n\r\n- Slicing methods could return a thick pointer instead of an `ArrayView/Mut` except in the `IxDyn` case.\r\n\r\n- *Raw* thick pointers (i.e. `*const`/`*mut`) would be more useful. In other words, since the shape/strides would be stored within the thick pointer itself, it should be possible to access that information without dereferencing the pointer. So, except in the `IxDyn` case, thick pointers could replace `RawArrayView/Mut`. In contrast, given a `*const ArrayRef\u003cA, D>` or `*mut ArrayRef\u003cA, D>`, you have to dereference the pointer to access the shape/strides, so `ArrayRef` cannot replace most uses of `RawArrayView/Mut`.\r\n\r\nHowever, I'm not aware of any Rust RFC for custom DSTs which would make it possible to create a custom DST with support for the dynamic-dimensional (`IxDyn`) case. So, there would be this weird dichotomy between the convenience of thick pointers for the const-dimensional case and the complexity of the dynamic-dimensional case. In contrast, the `ArrayRef` type proposed in this RFC would support the const-dimensional and dynamic-dimensional cases in a uniform way.\r\n\r\n# Future possibilities\r\n\r\nOne thing I wanted to make sure when writing this proposal was that it would still allow replacing the `ArrayBase` struct with a trait-based API in the future. In other words, if we had\r\n\r\n```rust\r\nstruct Array\u003cA, D> { ... }\r\n\r\nstruct ArrayView\u003c'a, A, D> { ... }\r\n\r\n// ...\r\n\r\ntrait NdArray { ... }\r\n\r\ntrait NdArrayMut { ... }\r\n\r\n// ...\r\n```\r\n\r\ninstead of having all arrays be instances of `ArrayBase`, it would be nice for this proposal to still apply. This proposal would, in fact, be compatible with a trait-based API, and the implementation could be somewhat cleaner because it wouldn't require any `unsafe` code. I'd suggest implementing the types like this:\r\n\r\n```rust\r\nstruct Array\u003cA, D> {\r\n    meta: ArrayRef\u003cA, D>,\r\n    data: Vec\u003cA>,\r\n}\r\n\r\nstruct ArrayView\u003c'a, A, D> {\r\n    meta: ArrayRef\u003cA, D>,\r\n    life: PhantomData\u003c&'a A>,\r\n}\r\n\r\nstruct ArrayRef\u003cA, D> {\r\n    shape: D,\r\n    strides: D,\r\n    ptr: NonNull\u003cA>,\r\n}\r\n\r\nimpl\u003cA, D> Deref for Array\u003cA, D> {\r\n    type Target = ArrayRef\u003cA, D>;\r\n\r\n    fn deref(&self) -> &ArrayRef\u003cA, D> {\r\n        &self.meta\r\n    }\r\n}\r\n\r\n// ...\r\n```\r\n","author":{"url":"https://github.com/jturner314","@type":"Person","name":"jturner314"},"datePublished":"2021-01-04T03:42:30Z","url":"https://github.com/rust-ndarray/ndarray/issues/879"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:20b2c0f6-e44d-99d8-84f3-bc8387a73868
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB37C:214E9D:5DD3F:865D4:6AFD488B
html-safe-nonce50ad0be7734b84a37ab8e2519be70cd1a1bc8ac055cf79127892580a8f17620e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzdDOjIxNEU5RDo1REQzRjo4NjVENDo2QUZENDg4QiIsInZpc2l0b3JfaWQiOiIyMDMzMzIzMjM0MzgzNzEwMzQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac0152de1abf8a35c18cadd1ed8c7182fd086765cdb4c48081190b7b775b59545f
hovercard-subject-tagissue:777792827
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/rust-ndarray/ndarray/879/issue_layout
twitter:imagehttps://opengraph.githubassets.com/34e5657d36d2a42c8a2fe5a14b6b7cff5b751e67d87090f81e2898b39bf30983/rust-ndarray/ndarray/issues/879
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/34e5657d36d2a42c8a2fe5a14b6b7cff5b751e67d87090f81e2898b39bf30983/rust-ndarray/ndarray/issues/879
og:image:altPlease post your thoughts, or let me know if something is unclear/confusing! Summary This RFC proposes the addition of a new storage type RefRepr and associated type aliases ArrayRef, ArrayRe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejturner314
hostnamegithub.com
expected-hostnamegithub.com
None66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e
turbo-cache-controlno-preview
go-importgithub.com/rust-ndarray/ndarray git https://github.com/rust-ndarray/ndarray.git
octolytics-dimension-user_id44419403
octolytics-dimension-user_loginrust-ndarray
octolytics-dimension-repository_id22598813
octolytics-dimension-repository_nworust-ndarray/ndarray
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id22598813
octolytics-dimension-repository_network_root_nworust-ndarray/ndarray
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb6f01f7cb9f35f8c09949773241a3d49dd04b340
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/rust-ndarray/ndarray/issues/879#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Frust-ndarray%2Fndarray%2Fissues%2F879
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Frust-ndarray%2Fndarray%2Fissues%2F879
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=rust-ndarray%2Fndarray
Reloadhttps://github.com/rust-ndarray/ndarray/issues/879
Reloadhttps://github.com/rust-ndarray/ndarray/issues/879
Reloadhttps://github.com/rust-ndarray/ndarray/issues/879
rust-ndarrayhttps://github.com/rust-ndarray
ndarrayhttps://github.com/rust-ndarray/ndarray
Codehttps://github.com/rust-ndarray/ndarray
Issues175 (175)https://github.com/rust-ndarray/ndarray/issues
Pull requests41 (41)https://github.com/rust-ndarray/ndarray/pulls
Discussionshttps://github.com/rust-ndarray/ndarray/discussions
Actionshttps://github.com/rust-ndarray/ndarray/actions
Projectshttps://github.com/rust-ndarray/ndarray/projects
Wikihttps://github.com/rust-ndarray/ndarray/wiki
Security and qualityhttps://github.com/rust-ndarray/ndarray/security
Insightshttps://github.com/rust-ndarray/ndarray/insights
https://github.com/rust-ndarray/ndarray
New issuehttps://github.com/login?return_to=https://github.com/rust-ndarray/ndarray/issues/879
New issuehttps://github.com/login?return_to=https://github.com/rust-ndarray/ndarray/issues/879
#1440https://github.com/rust-ndarray/ndarray/pull/1440
RFC: Array Reference Typehttps://github.com/rust-ndarray/ndarray/issues/879#top
#1440https://github.com/rust-ndarray/ndarray/pull/1440
breaking-changehttps://github.com/rust-ndarray/ndarray/issues?q=state%3Aopen%20label%3A%22breaking-change%22
enhancementhttps://github.com/rust-ndarray/ndarray/issues?q=state%3Aopen%20label%3A%22enhancement%22
0.17.0https://github.com/rust-ndarray/ndarray/milestone/9
https://github.com/jturner314
jturner314https://github.com/jturner314
on Jan 4, 2021https://github.com/rust-ndarray/ndarray/issues/879#issue-777792827
#878https://github.com/rust-ndarray/ndarray/issues/878
@blusshttps://github.com/bluss
RFC 2594https://github.com/rust-lang/rfcs/pull/2594
jturner314https://github.com/jturner314
enhancementhttps://github.com/rust-ndarray/ndarray/issues?q=state%3Aopen%20label%3A%22enhancement%22
breaking-changehttps://github.com/rust-ndarray/ndarray/issues?q=state%3Aopen%20label%3A%22breaking-change%22
on Jan 4, 2021https://github.com/rust-ndarray/ndarray/issues/879#event-4163204904
https://github.com/bluss
blusshttps://github.com/bluss
on Jan 4, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-754138627
https://github.com/jturner314
jturner314https://github.com/jturner314
on Jan 5, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-754313950
partition_muthttps://docs.rs/ndarray-stats/0.4.0/src/ndarray_stats/sort.rs.html#146-182
write_npyhttps://docs.rs/ndarray-npy/0.7.0/src/ndarray_npy/npy/mod.rs.html#202-229
https://github.com/bluss
blusshttps://github.com/bluss
on Jan 5, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-754322225
#819https://github.com/rust-ndarray/ndarray/pull/819
https://github.com/jturner314
jturner314https://github.com/jturner314
on Jan 5, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-754342223
methods implemented on ArrayBasehttps://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=19b6423a49449d078ea6fcc0c6197106
methods implemented on ArrayRefhttps://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8e5d6a68f4378b1ad7390213849565cc
https://github.com/bluss
blusshttps://github.com/bluss
on Jan 5, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-754597625
https://github.com/jturner314
jturner314https://github.com/jturner314
on Jan 5, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-754965963
This is a simplified, quick-and-dirty example in the playground.https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=abb28e65d063979df71b6c78f7389611
https://github.com/bluss
blusshttps://github.com/bluss
on Jan 6, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-755628664
https://github.com/jturner314
jturner314https://github.com/jturner314
on Jan 8, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-756513770
documents the C representation in detailhttps://doc.rust-lang.org/stable/reference/type-layout.html#the-c-representation
the reference says that it's okay to read padding byteshttps://doc.rust-lang.org/stable/reference/behavior-considered-undefined.html
https://github.com/bluss
blusshttps://github.com/bluss
on Jan 10, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-757393174
rust-lang/rfcs#2981https://github.com/rust-lang/rfcs/pull/2981
https://github.com/jturner314
jturner314https://github.com/jturner314
on Jan 10, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-757405532
Transmutes page of the Rustonomiconhttps://doc.rust-lang.org/nomicon/transmutes.html
Unsafe Code Guidelines Working Grouphttps://github.com/rust-lang/unsafe-code-guidelines
https://github.com/bluss
blusshttps://github.com/bluss
on Jan 10, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-757456094
https://stackoverflow.com/questions/9747010/does-accessing-the-first-field-of-a-struct-via-a-c-cast-violate-strict-aliasinghttps://stackoverflow.com/questions/9747010/does-accessing-the-first-field-of-a-struct-via-a-c-cast-violate-strict-aliasing
https://stackoverflow.com/questions/11639947/is-type-punning-through-a-union-unspecified-in-c99-and-has-it-become-specifiedhttps://stackoverflow.com/questions/11639947/is-type-punning-through-a-union-unspecified-in-c99-and-has-it-become-specified
blusshttps://github.com/bluss
0.16.0https://github.com/rust-ndarray/ndarray/milestone/2
on Jan 30, 2021https://github.com/rust-ndarray/ndarray/issues/879#event-4269266881
https://github.com/bluss
blusshttps://github.com/bluss
on Feb 4, 2021https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-773126014
blusshttps://github.com/bluss
0.16.0https://github.com/rust-ndarray/ndarray/milestone/2
0.17.0https://github.com/rust-ndarray/ndarray/milestone/9
on Mar 6, 2024https://github.com/rust-ndarray/ndarray/issues/879#event-12034470173
https://github.com/akern40
akern40https://github.com/akern40
on May 27, 2024https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-2132665713
@jturner314https://github.com/jturner314
comment abovehttps://github.com/rust-ndarray/ndarray/issues/879#issuecomment-756513770
herehttps://github.com/akern40/ndarray/tree/arrayref
https://github.com/akern40
akern40https://github.com/akern40
on Jul 2, 2024https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-2201817745
Trait specialization (RFC 1210)https://rust-lang.github.io/rfcs/1210-impl-specialization.html
(playground here)https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6ee6e1eac45b6db897d70a5a596f7316
can't use type parameters in const expressionshttps://github.com/rust-lang/rust/issues/76560
autoref specializationhttp://lukaskalbertodt.github.io/2019/12/05/generalized-autoref-based-specialization.html
https://github.com/grothesque
grothesquehttps://github.com/grothesque
on Jul 17, 2024https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-2233818859
@akern40https://github.com/akern40
https://github.com/akern40
akern40https://github.com/akern40
on Jul 19, 2024https://github.com/rust-ndarray/ndarray/issues/879#issuecomment-2240097753
@grothesquehttps://github.com/grothesque
first of many gistshttps://gist.github.com/akern40/cdf559ec1d508f926dcece0351a2ca3f#file-basic-design-rs
portraithttps://docs.rs/portrait/0.3.0/portrait/index.html
akern40https://github.com/akern40
completedhttps://github.com/rust-ndarray/ndarray/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#1440https://github.com/rust-ndarray/ndarray/pull/1440
on Mar 18, 2025https://github.com/rust-ndarray/ndarray/issues/879#event-16817833253
Sign up for freehttps://github.com/signup?return_to=https://github.com/rust-ndarray/ndarray/issues/879
Sign in to commenthttps://github.com/login?return_to=https://github.com/rust-ndarray/ndarray/issues/879
breaking-changehttps://github.com/rust-ndarray/ndarray/issues?q=state%3Aopen%20label%3A%22breaking-change%22
enhancementhttps://github.com/rust-ndarray/ndarray/issues?q=state%3Aopen%20label%3A%22enhancement%22
0.17.0No due datehttps://github.com/rust-ndarray/ndarray/milestone/9
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.