[PATCH V2] smartset: add a "toset" method

Martin von Zweigbergk martinvonz at google.com
Sat Jun 3 20:55:23 EDT 2017


On Jun 3, 2017 5:02 PM, "Augie Fackler" <raf at durin42.com> wrote:


> On Jun 3, 2017, at 7:29 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.
org> wrote:
>
>>> +    def toset(self):
>>> +        return self._set
>>
>> It freaks me out just a little (maybe too much Rust today?) to leak
self._set mutably like this. What do you think of making a copy? Should we
just strongly admonish in the “convert to a set” docstring that callers of
toset() _must not_ mutate the returned set?
>
> Note: For the target code, copying sets is can be multiple percent of the
total run time.

Okay, it sounds like we should document that the API contract is that
clients must not mutate the returned set. Does that sound workable to
everyone?


Sounds good to me.

But I think the argument about "multiple percent of the total run time" is
pretty silly when the total run time is about a millisecond (IIUC).

_______________________________________________
Mercurial-devel mailing list
Mercurial-devel at mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170603/21bf51d3/attachment.html>


More information about the Mercurial-devel mailing list