Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slice(): Rewrite to return view instead of copy #176

Closed
mateogianolio opened this issue Aug 7, 2019 · 0 comments · Fixed by #207
Closed

slice(): Rewrite to return view instead of copy #176

mateogianolio opened this issue Aug 7, 2019 · 0 comments · Fixed by #207

Comments

@mateogianolio
Copy link
Owner

Related

Notes

Following numpy's philosophy; it is more often more efficient to return a view of the data when slicing, transposing, etc. Slicing should return a view of the old data instead of allocating more memory.

This way, the following would be possible:

const x = v.array.range(0, 4);
// x: [[0, 1], [2, 3]]

const y = x.slice(0, 2);
// y: [0, 1]

const z = v.ones(2);
// z: [1, 1]

y.add(z);
// y: [1, 2]

// x: [1, 2, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant