<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Priority Queue on Nalar</title>
    <link>https://nalar.dev/tags/priority-queue/</link>
    <description>Recent content in Priority Queue on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 08 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/priority-queue/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Use Native Max-Heaps with Python heapq</title>
      <link>https://nalar.dev/use-native-max-heaps-with-python-heapq/</link>
      <pubDate>Tue, 08 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/use-native-max-heaps-with-python-heapq/</guid>
      <description>&lt;p&gt;Python&amp;rsquo;s &lt;code&gt;heapq&lt;/code&gt; module has historically been centered on min-heaps: the smallest element lives at index zero. Developers who needed a max-heap commonly negated numeric priorities before pushing them and negated them again after popping.&lt;/p&gt;&#xA;&lt;p&gt;Python 3.14 makes that workaround unnecessary for many programs. &lt;code&gt;heapq&lt;/code&gt; now exposes a complete max-heap API: &lt;code&gt;heapify_max()&lt;/code&gt;, &lt;code&gt;heappush_max()&lt;/code&gt;, &lt;code&gt;heappop_max()&lt;/code&gt;, &lt;code&gt;heappushpop_max()&lt;/code&gt;, and &lt;code&gt;heapreplace_max()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The new functions are simple, but using them well still requires understanding heap invariants, fixed-size selection, tie-breaking, and the important difference between push-pop and replace operations.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
