<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Maybe, that suffices: <a class="moz-txt-link-freetext" href="https://pypi.python.org/pypi/xheap">https://pypi.python.org/pypi/xheap</a><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 21.11.2017 03:46, bunslow wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAAWJOpYETVMvG5=6G1Y9mm1a3-Z11ts0HcRPzJgkTO+Uv+BqeA@mail.gmail.com">
      <div dir="ltr"><span style="font-size:12.8px">Perhaps such
          repetition is a sign that *something* needs to be done...</span>
        <div style="font-size:12.8px"><br>
        </div>
        <div style="font-size:12.8px">Thanks for the link though. I'm
          new enough to the community that it didn't even occur to me to
          search for prior discussions.</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Nov 20, 2017 at 8:38 PM,
          Sebastian Kreft <span dir="ltr"><<a
              href="mailto:skreft@gmail.com" target="_blank"
              moz-do-not-send="true">skreft@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">This has been brought up multiple times. Last
              time was on this thread <a
href="https://mail.python.org/pipermail/python-ideas/2016-October/043024.html"
                target="_blank" moz-do-not-send="true">https://mail.python.<wbr>org/pipermail/python-ideas/<wbr>2016-October/043024.html</a>.</div>
            <div class="gmail_extra"><br>
              <div class="gmail_quote">
                <div>
                  <div class="h5">On Tue, Nov 21, 2017 at 3:13 AM,
                    bunslow <span dir="ltr"><<a
                        href="mailto:bunslow@gmail.com" target="_blank"
                        moz-do-not-send="true">bunslow@gmail.com</a>></span>
                    wrote:<br>
                  </div>
                </div>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div>
                    <div class="h5">
                      <div dir="ltr">Nothing so bombastic this time. The
                        heapq functions are basically all named
                        "heapsomething", and basically all take a "heap"
                        for their first argument, with supplementary
                        args coming after. It's a textbook example of
                        the (hypothetical) Object Oriented Manifesto™
                        where defining a class increases type safety and
                        programmers' conceptual clarity. There're
                        practically no drawbacks, and the code to be
                        added would be very simple. Updating the tests
                        and docs would probably be harder.
                        <div><br>
                        </div>
                        <div>In pure Python, such a class would look
                          like this:</div>
                        <div><br>
                        </div>
                        <div>
                          <div>class Heap(list):</div>
                          <div><br>
                          </div>
                          <div>    def __init__(self, iterable=None):</div>
                          <div>        if iterable:</div>
                          <div>            super().__init__(iterable)</div>
                          <div>        else:</div>
                          <div>            super().__init__()<br>
                            <br>
                          </div>
                          <div>        self.heapify()</div>
                          <div><br>
                          </div>
                          <div>    push = heapq.heappush</div>
                          <div>    pop = heapq.heappop</div>
                          <div>    pushpop = heapq.heappushpop</div>
                          <div>    replace = heapq.heapreplace</div>
                          <div>    heapify = heapq.heapify</div>
                          <div><br>
                          </div>
                          <div>    # This could be a simple wrapper as
                            well, but I had the following thoughts
                            anyways, so here they are</div>
                          <div>    def nsmallest(self, n, key=None):</div>
                          <div>        # heapq.nsmallest makes a *max*
                            heap of the first n elements,</div>
                          <div>        # while we know that self is
                            already a min heap, so we can</div>
                          <div>        # make the max heap construction
                            faster</div>
                          <div>        self[:n] = reversed(self[:n])</div>
                          <div>        return heapq.nsmallest(n, self,
                            key)</div>
                          <div><br>
                          </div>
                          <div>    # do we define nlargest on a
                            minheap??<br>
                            <br>
                            <br>
                            Wrapping around the C builtin functions
                            (which aren't descriptors) would be a bit
                            harder, but not much so:</div>
                        </div>
                        <div><br>
                        </div>
                        <div>from functools import partial</div>
                        <div><br>
                        </div>
                        <div>class Heap(list):</div>
                        <div>    def __init__(self, iterable=None):</div>
                        <div>        if iterable:</div>
                        <div>            super().__init__(iterable)</div>
                        <div>        else:</div>
                        <div>            super().__init__()</div>
                        <div><br>
                        </div>
                        <div>        self.heapify =
                          partial(heapq.heapify, self)</div>
                        <div>        self.push = partial(heapq.heappush,
                          self)</div>
                        <div>        ...</div>
                        <div><br>
                        </div>
                        <div>        self.heapify()</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>Thoughts?</div>
                      </div>
                      <br>
                    </div>
                  </div>
                  ______________________________<wbr>_________________<br>
                  Python-ideas mailing list<br>
                  <a href="mailto:Python-ideas@python.org"
                    target="_blank" moz-do-not-send="true">Python-ideas@python.org</a><br>
                  <a
                    href="https://mail.python.org/mailman/listinfo/python-ideas"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
                  Code of Conduct: <a
                    href="http://python.org/psf/codeofconduct/"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">http://python.org/psf/codeofco<wbr>nduct/</a><br>
                  <br>
                </blockquote>
              </div>
              <span class="HOEnZb"><font color="#888888"><br>
                  <br clear="all">
                  <div><br>
                  </div>
                  -- <br>
                  <div class="m_3208241631053169745gmail_signature"
                    data-smartmail="gmail_signature">Sebastian Kreft</div>
                </font></span></div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Python-ideas mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Python-ideas@python.org">Python-ideas@python.org</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a>
Code of Conduct: <a class="moz-txt-link-freetext" href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>