perf: don't depend on pycompat for older Mercurial versions
We already define local _sysstr() and _xrange() for compatibility, so
we should use those.
Also create a similar local _bytestr() corresponding to
pycompat.bytestr().
Differential Revision: https://phab.mercurial-scm.org/D6745