pycompat.py strategy

Raphaël Gomès raphael.gomes at octobus.net
Tue Feb 22 16:15:48 UTC 2022


On 2/21/22 19:47, Gregory Szorc wrote:
> I'm ~100 patches deep into purging Python 2 from the main repo. (I 
> think I'll hold off submitting them until 6.1 is out the door.)
>
Thanks, we indeed need the focus on the current release, I'll be happy 
to review them after the freeze.
> Much of the Python 2 deletion work is trivial. But one question that 
> isn't trivial is what to do with pycompat.py.
>
> Some options:
>
> a) Attempt to delete as much as pycompat.py as possible (leaving only 
> the pieces needed to abstract over differences in Python 3.5-3.x).
> b) Leave the ~complete API provided by pycompat.py and delete pycompat 
> usage within the repo as much as possible.
> c) Leave the ~complete API provided by pycompat.py and still use 
> pycompat heavily within the repo.
>
> In my series, I'm going with "b" because after deletion of Python 2, 
> many of the abstractions in Python 2 no longer make much sense and 
> their presence doesn't accomplish much except confuse people through 
> extra indirection. Things like pycompat.iteritems() (which is just a 
> proxy to .items()) don't serve any purpose any more and IMO shouldn't 
> be used.
>
> Other parts of pycompat are harder to delete. e.g. strkwargs() and 
> byteskwargs() are used pretty heavily and form an API contract. So I 
> anticipate we'll be living with them for a while.
>
> As much as I would like to delete APIs from pycompat.py entirely, I 
> think we should keep them around so extensions have a stable API to 
> manage the Python 2 -> 3 and <=6.1 to >6.1 migrations. However, I 
> think we should establish a schedule for marking them as deprecated 
> and deleting them. This schedule should be independent of their usage 
> within the repo, as the two decisions are separate.
>
> Thoughts?
>
I agree that we really shouldn't delete pycompat stuff during the 6.2 
cycle, and I'm not entirely convinced that deleting any of it is worth 
it at any point. Keeping around the module shouldn't impact core in the 
long run and can avoid breakage for external code for the low price of 
some small amount of dead code.


Raphaël

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list