Skip to content

Commit 2b9fd97

Browse files
committed
Don't allocate an extra tuple element
For some reason CPython allocates an extra "item" for generic variable-sized objects, but it looks like it doesn't do that for tuples. We had been doing that, so let's try not doing that and saving 8 bytes per tuple.
1 parent d50f760 commit 2b9fd97

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/runtime/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ class BoxedTuple : public BoxVar {
613613
assert(tuple_cls->is_pyston_class);
614614
assert(tuple_cls->attrs_offset == 0);
615615

616-
void* mem = gc_alloc(sizeof(BoxedTuple) + nitems * sizeof(Box*), gc::GCKind::PYTHON);
616+
void* mem = gc_alloc(offsetof(BoxedTuple, elts) + nitems * sizeof(Box*), gc::GCKind::PYTHON);
617617
assert(mem);
618618

619619
BoxVar* rtn = static_cast<BoxVar*>(mem);

0 commit comments

Comments
 (0)