<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Functools on Nalar</title>
    <link>https://nalar.dev/tags/functools/</link>
    <description>Recent content in Functools on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 02 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/functools/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Cache Pure Work in Python with functools.cache and lru_cache</title>
      <link>https://nalar.dev/cache-pure-work-with-functools-cache-and-lru-cache/</link>
      <pubDate>Wed, 02 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/cache-pure-work-with-functools-cache-and-lru-cache/</guid>
      <description>&lt;p&gt;Caching can turn repeated expensive work into a dictionary lookup, but it can also return stale data or grow memory without bound. Python&amp;rsquo;s &lt;code&gt;functools&lt;/code&gt; module provides two convenient memoization decorators: &lt;code&gt;lru_cache&lt;/code&gt; and &lt;code&gt;cache&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;functools.cache&lt;/code&gt; has been available since Python 3.9. It is effectively an unbounded memoization cache. &lt;code&gt;lru_cache&lt;/code&gt; adds a configurable size limit and eviction behavior.&lt;/p&gt;&#xA;&lt;h2 id=&#34;cache-functions-not-arbitrary-side-effects&#34;&gt;Cache functions, not arbitrary side effects&lt;/h2&gt;&#xA;&lt;p&gt;Memoization works best when a function behaves like a pure function: the result depends only on its arguments.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
