Accurately measure python core fragmentation

Greetings folks, I am new to this. I was wondering how to accurately “debug” pymalloc, but also get a pretty accurate measurment of python’s fragmentation using python’s internal. I peeked the source code, I asked AI, but I am not sure how it works.

To the people who where in part of the python core development

  1. How do I measure fragmentation in python core accurately ? (My approach would be to use some kind of diffing like vmrss vs internals or tools like memray)
  2. How do I learn how to debug such complex thing as a production-grade allocator
  3. Does it matter in the AI era ?

Thank you in advance