Is there something similar in Python that I would use for a container that's like a vector and a list?
Any links would be helpful too.
Vectors are much more similar to Python lists than arrays are. Vectors use a dynamically allocated array to store their elements, so they can change size, and they have other friendly features as well.
Vector may have a default size. List does not have default size. In vector, each element only requires the space for itself only. In list, each element requires extra space for the node which holds the element, including pointers to the next and previous elements in the list.
The STL vector Container. The vector class implements a dynamic array that provides fast insertion at the end, fast random access to its components, and automatically resizes itself when components are inserted or deleted.
You can use the inbuilt list - underlying implementation is similar to C++ vector. Although some things differ - for example, you can put objects of different type in one and the same list.
http://effbot.org/zone/python-list.htm
N.B.: Please keep in mind that vector and list are two very different data structures. List are heterogeneous, i.e. can store different object types, while C++ vectors are homogeneous. The data in vectors is stored in linear arrangement whereas in list is a collection of references to the type and the memory address of the variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With