Should we fuse Python's array class and mojo's DynamicVector's struct?
They are extremely similar.
Here is the documentation for array: https://docs.python.org/3/library/array.html
Here is the documentation for DynamicVector:
https://docs.modular.com/mojo/stdlib/utils/vector.html#dynamicvector
With just a few more attributes and methods, Python's array could become a DynamicVector. If Mojo wants to be a good member of the Python family, maybe we should not reinvent what's already in the stdlib.
Python documentation
array — Efficient arrays of numeric values
This module defines an object type which can compactly represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, e...
Modular Docs - vector
Module
3 Replies
Mojo's
DynamicVector
is closer to Python's list
-- a better equivalent to Python's array
is Mojo's Tensor
. (DynamicVector
s are resizeable dynamically; Tensor
shapes are fixed at creation time.) That said, Mojo's standard library is in a very early state right now, and is changing rapidly. In particular, many useful things are not possible yet because traits are not ready yet. As the language develops further, we expect it will get closer to Python.Great! Thanks for the detailed answer, though it seems there is a slightly misunderstanding, Python's array are resizable dynamically:
Though of course that doesn't invalidate your answer. I'll be waiting for traits 🙂
Congrats @gabrieldemarmiesse, you just advanced to level 3!