Skip to content

Commit 533cbd3

Browse files
committed
Address feedback
1 parent 190b1de commit 533cbd3

5 files changed

Lines changed: 7 additions & 9 deletions

File tree

mypyc/irbuild/expression.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,8 @@ def transform_call_expr(builder: IRBuilder, expr: CallExpr) -> Value:
368368
if len(expr.args) == 0 or (len(expr.args) == 1 and expr.arg_kinds == [ARG_NAMED]):
369369
# vec[T]() or vec[T](capacity=N)
370370
return vec_create(builder.builder, vec_type, 0, expr.line, capacity=capacity)
371-
elif (
372-
len(expr.args) == 1
373-
and expr.arg_kinds == [ARG_POS]
374-
or len(expr.args) == 2
375-
and expr.arg_kinds == [ARG_POS, ARG_NAMED]
371+
elif (len(expr.args) == 1 and expr.arg_kinds == [ARG_POS]) or (
372+
len(expr.args) == 2 and expr.arg_kinds == [ARG_POS, ARG_NAMED]
376373
):
377374
# vec[T](items) or vec[T](items, capacity=N)
378375
return translate_vec_create_from_iterable(

mypyc/lib-rt/vecs/vec_nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ PyTypeObject VecNestedType = {
569569
};
570570

571571
PyObject *VecNested_FromIterable(size_t item_type, size_t depth, PyObject *iterable, int64_t cap) {
572-
VecNested v = vec_alloc(cap > 0 ? cap : 0, item_type, depth);
572+
VecNested v = vec_alloc(cap, item_type, depth);
573573
if (VEC_IS_ERROR(v))
574574
return NULL;
575575
if (cap > 0) {

mypyc/lib-rt/vecs/vec_t.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ PyTypeObject VecTType = {
562562
};
563563

564564
PyObject *VecT_FromIterable(size_t item_type, PyObject *iterable, int64_t cap) {
565-
VecT v = vec_alloc(cap > 0 ? cap : 0, item_type);
565+
VecT v = vec_alloc(cap, item_type);
566566
if (VEC_IS_ERROR(v))
567567
return NULL;
568568
if (cap > 0) {

mypyc/lib-rt/vecs/vec_template.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ VEC FUNC(New)(Py_ssize_t size, Py_ssize_t cap) {
101101
}
102102

103103
PyObject *FUNC(FromIterable)(PyObject *iterable, int64_t cap) {
104-
VEC v = vec_alloc(cap > 0 ? cap : 0);
104+
VEC v = vec_alloc(cap);
105105
if (VEC_IS_ERROR(v))
106106
return NULL;
107107
if (cap > 0) {

mypyc/test-data/run-vecs-t-interp.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,8 @@ def test_cap_reallocation() -> None:
587587
old = v
588588
v = append(v, 'c')
589589
old = append(old, 'Q')
590-
assert v[0] == 'a'
590+
assert v[2] == 'c'
591+
assert old[2] == 'Q'
591592

592593
# Old alias retains original items after reallocation
593594
v = vec[str](['a', 'b', 'c'], capacity=3)

0 commit comments

Comments
 (0)