<div dir="ltr"><div>I have implemented a C preprocessor written in Python which gives some useful visualisations of source code, particularly macro usage: <a href="https://github.com/paulross/cpip" target="_blank">https://github.com/paulross/<wbr>cpip</a></div><div><br></div><div>I have been running this on the CPython source code and it occurs to me that this might be useful to the python-dev community.</div><div><br></div><div>For example the Python dictionary source code is visualised here: <a href="http://cpip.readthedocs.io/en/latest/_static/dictobject.c/index_dictobject.c_a3f5bfec1ed531371fb1a2bcdcb2e9c2.html" target="_blank">http://cpip.readthedocs.io/en/<wbr>latest/_static/dictobject.c/<wbr>index_dictobject.c_<wbr>a3f5bfec1ed531371fb1a2bcdcb2e9<wbr>c2.html</a> I found this really useful when I was getting a segfault during a dictionary insert from my C code. The segfault was on this line <a href="http://cpip.readthedocs.io/en/latest/_static/dictobject.c/dictobject.c_a3f5bfec1ed531371fb1a2bcdcb2e9c2.html#1130" target="_blank">http://cpip.readthedocs.io/en/<wbr>latest/_static/dictobject.c/<wbr>dictobject.c_<wbr>a3f5bfec1ed531371fb1a2bcdcb2e9<wbr>c2.html#1130</a> but it is hard to see what is going on with macros inside macros. If you click on the link on the left end of the line it takes you to the full expansion of the macros <a href="http://cpip.readthedocs.io/en/latest/_static/dictobject.c/dictobject.c.html#1130" target="_blank">http://cpip.readthedocs.io/en/<wbr>latest/_static/dictobject.c/<wbr>dictobject.c.html#1130</a> as this is what the compiler and debugger see.</div><div>I could examine these values in GDB and figure out what was going on. I could also figure what that MAINTAIN_TRACKING macro was doing by looking at the macros page generated by CPIP: <a href="http://cpip.readthedocs.io/en/latest/_static/dictobject.c/macros_ref.html#_TUFJTlRBSU5fVFJBQ0tJTkdfMA__" target="_blank">http://cpip.readthedocs.io/en/<wbr>latest/_static/dictobject.c/<wbr>macros_ref.html#_<wbr>TUFJTlRBSU5fVFJBQ0tJTkdfMA__</a> and following those links.</div><div><br></div><div>I was wondering if it would be valuable to python-dev developers if this tool was run regularly over the CPython source tree(s). A single source tree takes about 12 CPU hours to process and generates 8GB of HTML/SVG. If this is useful then where to host this?</div><div><br></div><div>Regards,</div><div><br></div><div>Paul Ross</div><div><br></div></div>