Skip to content

Commit 443edc4

Browse files
committed
Small updates
1 parent 6f9bd02 commit 443edc4

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

mypyc/doc/librt_vecs.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,16 @@ The ``vec`` class
8181
A generic growable array type. The runtime type parameter ``T`` used when
8282
calling ``vec[T](...)`` determines the element type.
8383

84-
The ``capacity`` parameter allows defining the initial
85-
minimum capacity of the buffer, some of which may be unused after
84+
The ``capacity`` parameter allows defining the minimum initial
85+
capacity of the buffer, some of which may be unused after
8686
construction. Unused capacity allows fast ``append`` and ``extend``
87-
operations that don't need to reallocate the buffer.
87+
operations that don't need to reallocate the buffer. Actual capacity
88+
will be larger than ``capacity`` if ``items`` has more than ``capacity``
89+
items.
90+
91+
Mypyc treats ``vec[T]([x] * n)`` as a special form. For example,
92+
``vec[u8]([0] * n)`` constructs a zero-initialized vec object
93+
efficiently, without building an intermediate list.
8894

8995
It's an error to construct a ``vec`` object without providing an
9096
item type: ``vec()`` raises an exception.

0 commit comments

Comments
 (0)