-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-121970: Extract pydoc_topics
into a new extension
#129116
Conversation
On macOS, The file also reduced from 830 KB to 519 KB. However, I don't have any Python 3.13.1 (v3.13.1:06714517797, Dec 3 2024, 14:00:22) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import runpy
>>> topics_old = runpy.run_path("topics_old.py")['topics']
>>> topics_new = runpy.run_path("topics_new.py")['topics']
>>> assert list(topics_old) == list(topics_new) # check order
>>> [k for k in topics_old if topics_old[k] != topics_new[k]]
[]
>>> |
Wonderful! I think I may have been testing with Sphinx 8.1 vs 8.2 (unreleased), as I made a change to how the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @hugovk as 3.14 release manager as this does change the format of
Lib/pydoc_data/topics.py
. I'm happy when doing backports to preserve the current format (pformat
) if release managers would prefer.
I'm okay with it, but then there are no backports to 3.14 🙃
Ok, let's merge this and then ask @Yhg1s what he thinks about backporting to 3.13 and 3.12. I'm assuming the backports will fail due to the change to A |
Thanks @AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, @AA-Turner, I could not cleanly backport this to
|
Sorry, @AA-Turner, I could not cleanly backport this to
|
This also simplifies the
pydoc-topics
builder. Grouping the topic labels by docname improves the speed of topics generation from ~68s to ~57s (19% faster) from a cold state, and from ~13s to ~3.4s (3.8x faster) when re-using the pickled documents.The representation of
topics.py
also changes from the defaultpprint.pformat
output of:to a simpler representation using triple single quotes (save for when
'''
appears in the body):This representation is both nicer to read and is 63% of the file size of the current
topics.py
(518KB vs 830KB). Line count also decreases from 17,486 to 12,782.Tested by running:
The
'formatstrings'
change is trailing whitespace on the>>> for num in range(5,12):
line:The 'debugger' change is
"Ctrl-C"
to"Ctrl"-"C"
, but I'm not sure what caused this:cc @hugovk as 3.14 release manager as this does change the format of
Lib/pydoc_data/topics.py
. I'm happy when doing backports to preserve the current format (pformat
) if release managers would prefer.A
pyspecific
#121970📚 Documentation preview 📚: https://cpython-previews--129116.org.readthedocs.build/