Skip to content

Reduce padding in parser memo entries #160245

Closed

Description

@ashm-dev

Feature or enhancement

On an x86-64 GCC build, Memo in Parser/pegen.h occupies 32 bytes. Its current field order is:

int type;
void *node;
int mark;
struct _memo *next;

This introduces two 4-byte alignment gaps. Moving mark immediately after type reduces the structure to 24 bytes without changing any field types.

These entries are allocated through _PyArena_Malloc(), which rounds allocations to 8-byte boundaries. The proposed layout therefore saves 8 bytes per entry within the arena.

The size reduction was verified with a standalone GCC layout check.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added a commit that references this issue on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetopic-parsertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions