[PATCH 05 of 11] manifest: coerce _msearch argument to bytestr at method start

Yuya Nishihara yuya at tcha.org
Mon Mar 27 09:21:13 EDT 2017


On Mon, 27 Mar 2017 11:49:45 +0530, Pulkit Goyal wrote:
> Yuya had a different approach on this
> https://patchwork.mercurial-scm.org/patch/19682/

[...]

> On Mon, Mar 27, 2017 at 4:06 AM, Augie Fackler <raf at durin42.com> wrote:
> > # HG changeset patch
> > # User Augie Fackler <raf at durin42.com>
> > # Date 1490567242 14400
> > #      Sun Mar 26 18:27:22 2017 -0400
> > # Node ID d5dcfa6b2e20183ba2d6e439a23f5f2f4bf7981e
> > # Parent  54631fab906cb662e370ce313a0395292f7dfa15
> > manifest: coerce _msearch argument to bytestr at method start
> >
> > This potentially incurs some extra copies, but on Python 3 you can't
> > do comparisons between memoryview and bytes sequences. I have a
> > sneaking suspicion there are potential bugs in Python 2 lurking that
> > this might fix (but I have no way of proving this theory), so I'm not
> > going to sweat the risk of extra overhead here.

We use buffer() on Python 2, which returns bytes for slicing operation.
That's why 'm[start:end] < s' works on Python 2. OTOH, memoryview() can't
be used in that way.


More information about the Mercurial-devel mailing list