( )⚙ D3441 pycompat: export queue module instead of symbols in module (API)

This is an archive of the discontinued Mercurial Phabricator instance.

pycompat: export queue module instead of symbols in module (API)
ClosedPublic

Authored by indygreg on May 5 2018, 9:58 PM.

Details

Summary

Previously, pycompat and util re-exported individual symbols from the
queue module. This had the side-effect of forcing the loading of the
queue module whenever pycompat/util was imported.

These symbols aren't used very often. So importing the module to
get a handle on the symbols is wasteful.

This commit changes pycompat so it no longer exports the individual
symbols in the queue module. Instead, we make the imported module
a "public" symbol. We drop the individual symbol aliases from the
util module. All consumers are updated to use pycompat.queue.* instead.

This change makes 300 invocations of hg log -r. -T '{rev}\n' a little
faster:

before: 18.44s
after: 17.87s

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.May 5 2018, 9:58 PM
martinvonz accepted this revision.May 6 2018, 12:18 AM
martinvonz added a subscriber: martinvonz.
martinvonz added inline comments.
contrib/check-code.py
343–345

Maybe these should be "pycompat.queue.Queue" and "pycompat.queue.Empty" instead?

This revision is now accepted and ready to land.May 6 2018, 12:18 AM
indygreg added inline comments.May 6 2018, 12:21 AM
contrib/check-code.py
343–345

Yes, they should. Will you fix in flight or do you want another submit?

martinvonz added inline comments.May 6 2018, 12:22 AM
contrib/check-code.py
343–345

I can fix. Thanks for confirming quickly, because I wasn't confident enough to just change it.

This revision was automatically updated to reflect the committed changes.