<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Tech in General: Software Engineering]]></title><description><![CDATA[Here i post, content related to python.]]></description><link>https://nandigamharikrishna.substack.com/s/python</link><image><url>https://substackcdn.com/image/fetch/$s_!Tfzn!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a6e4139-3a50-4e10-a948-14b8e8a2feb4_608x608.png</url><title>Tech in General: Software Engineering</title><link>https://nandigamharikrishna.substack.com/s/python</link></image><generator>Substack</generator><lastBuildDate>Sat, 23 May 2026 04:09:39 GMT</lastBuildDate><atom:link href="https://nandigamharikrishna.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[N Hari Krishna (AI/ML)]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[nandigamharikrishna@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[nandigamharikrishna@substack.com]]></itunes:email><itunes:name><![CDATA[Hari Krishna]]></itunes:name></itunes:owner><itunes:author><![CDATA[Hari Krishna]]></itunes:author><googleplay:owner><![CDATA[nandigamharikrishna@substack.com]]></googleplay:owner><googleplay:email><![CDATA[nandigamharikrishna@substack.com]]></googleplay:email><googleplay:author><![CDATA[Hari Krishna]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Bloom Filters Explained: The Complete Deep Dive Into the Cleverest Data Structure You Will Ever Use]]></title><description><![CDATA[Bloom filters are widely used Data Structures and is very important to understand modern products. This blog covers all the advance concepts as well as real world use cases.]]></description><link>https://nandigamharikrishna.substack.com/p/bloom-filters-explained-the-complete</link><guid isPermaLink="false">https://nandigamharikrishna.substack.com/p/bloom-filters-explained-the-complete</guid><dc:creator><![CDATA[Hari Krishna]]></dc:creator><pubDate>Mon, 18 May 2026 04:19:17 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!RssB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RssB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RssB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 424w, https://substackcdn.com/image/fetch/$s_!RssB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 848w, https://substackcdn.com/image/fetch/$s_!RssB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 1272w, https://substackcdn.com/image/fetch/$s_!RssB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RssB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png" width="1456" height="773" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:773,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1021216,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RssB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 424w, https://substackcdn.com/image/fetch/$s_!RssB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 848w, https://substackcdn.com/image/fetch/$s_!RssB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 1272w, https://substackcdn.com/image/fetch/$s_!RssB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ee90661-1724-4ce4-ad2d-23b3a3818244_1500x796.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Here is a problem you probably have not thought deeply about. You have a billion URLs. A user submits a URL. You need to check if you have seen it before. You cannot hold a billion URLs in RAM. A disk lookup for every check would be too slow.</p><p>Or: you have a database of 2 billion usernames. Someone is trying to register. Before touching the database at all, you want to instantly know whether &#8220;alice&#8221; is already taken. Storing all those strings in a hash map consumes 30 to 50 gigabytes of RAM. That is not a practical option.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lS68!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lS68!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 424w, https://substackcdn.com/image/fetch/$s_!lS68!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 848w, https://substackcdn.com/image/fetch/$s_!lS68!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 1272w, https://substackcdn.com/image/fetch/$s_!lS68!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lS68!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png" width="1456" height="719" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:719,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:859415,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lS68!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 424w, https://substackcdn.com/image/fetch/$s_!lS68!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 848w, https://substackcdn.com/image/fetch/$s_!lS68!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 1272w, https://substackcdn.com/image/fetch/$s_!lS68!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33e4757f-27f7-4a57-b44c-571e5f3a8a60_1536x758.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Or: Google Chrome needs to warn users about malicious URLs. The list of known phishing sites is 50 megabytes. Sending that file to every browser on every update is wasteful. There is a smarter way.</p><p>All of these share the same shape: you need to check membership in a very large set, cheaply, without storing the actual data. Bloom filters solve this with a probabilistic approach that is, once you understand it, surprisingly elegant.</p><p>This guide goes deep. Not just the mechanics, but the mathematics, the edge cases, the misconceptions, the advanced variants, and the real systems that depend on them right now.</p><div><hr></div><h2><strong>The Problem Traditional Data Structures Cannot Solve</strong></h2><p>Before understanding Bloom filters, you need to understand exactly why traditional approaches fail at scale.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AwAT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AwAT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 424w, https://substackcdn.com/image/fetch/$s_!AwAT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 848w, https://substackcdn.com/image/fetch/$s_!AwAT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 1272w, https://substackcdn.com/image/fetch/$s_!AwAT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AwAT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png" width="1456" height="786" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:786,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1798538,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AwAT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 424w, https://substackcdn.com/image/fetch/$s_!AwAT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 848w, https://substackcdn.com/image/fetch/$s_!AwAT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 1272w, https://substackcdn.com/image/fetch/$s_!AwAT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F534af729-3a5e-4080-93d5-f9a0992e6e29_1618x874.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Hash tables and hash maps</strong> are the natural first instinct. You hash the element, look it up, done. The problem is memory. A hash map must store the actual keys. For 1 billion 20-byte strings, you are looking at 20 GB of raw key storage, plus the hash table overhead of roughly 30 to 50% more for pointers and load factor management. You end up needing 30 to 50 GB of RAM just for keys. Most machines do not have that available for a single lookup structure.</p><p><strong>Binary search trees</strong> are worse. Every node carries pointers to children, and traversal involves multiple memory accesses. At a billion elements, tree traversal generates serious cache thrashing because nodes are scattered across memory rather than contiguous.</p><p><strong>Disk-based lookups</strong> introduce latency measured in milliseconds. For a system doing millions of membership checks per second, that is unacceptable.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!am-4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!am-4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 424w, https://substackcdn.com/image/fetch/$s_!am-4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 848w, https://substackcdn.com/image/fetch/$s_!am-4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 1272w, https://substackcdn.com/image/fetch/$s_!am-4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!am-4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png" width="1456" height="770" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:770,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1526369,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!am-4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 424w, https://substackcdn.com/image/fetch/$s_!am-4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 848w, https://substackcdn.com/image/fetch/$s_!am-4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 1272w, https://substackcdn.com/image/fetch/$s_!am-4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02ab7fe7-bf71-4b48-920b-9ba5bab67685_1550x820.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The Bloom filter&#8217;s insight is radical: <strong>never store the actual data at all</strong>. Instead, store a tiny digital fingerprint of the data in a bit array. Sacrifice certainty of yes answers (false positives become possible) to achieve perfect certainty of no answers (false negatives are impossible) while using a fraction of the memory.</p><p>This is not a compromise. For the majority of use cases where the cost of an unnecessary operation is low and the cost of a missed operation is high, this is exactly the right tradeoff.</p><div><hr></div><h2><strong>The Core Idea: Bits and Multiple Hash Functions</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jZ66!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jZ66!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 424w, https://substackcdn.com/image/fetch/$s_!jZ66!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 848w, https://substackcdn.com/image/fetch/$s_!jZ66!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 1272w, https://substackcdn.com/image/fetch/$s_!jZ66!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jZ66!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png" width="1456" height="789" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:789,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1602018,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jZ66!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 424w, https://substackcdn.com/image/fetch/$s_!jZ66!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 848w, https://substackcdn.com/image/fetch/$s_!jZ66!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 1272w, https://substackcdn.com/image/fetch/$s_!jZ66!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52228c8c-6904-4dc1-9f4e-47f76ff69769_1562x846.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A Bloom filter has two components:</p><p><strong>A bit array of size m</strong>, initially all zeros. Every position in the array stores a single bit, either 0 or 1.</p><p><strong>k independent hash functions</strong>, each of which maps any input to a position in the bit array uniformly at random.</p><p><strong>To insert an element:</strong> Run it through all k hash functions. Set the bit at each resulting position to 1. You are not storing the element itself anywhere. You are only recording that some element hashed to these positions.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Upkd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Upkd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 424w, https://substackcdn.com/image/fetch/$s_!Upkd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 848w, https://substackcdn.com/image/fetch/$s_!Upkd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 1272w, https://substackcdn.com/image/fetch/$s_!Upkd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Upkd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png" width="1456" height="658" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:658,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:658526,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Upkd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 424w, https://substackcdn.com/image/fetch/$s_!Upkd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 848w, https://substackcdn.com/image/fetch/$s_!Upkd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 1272w, https://substackcdn.com/image/fetch/$s_!Upkd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35be8bc-5ed8-42a4-a63c-db32e250d527_1580x714.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>To check if an element exists:</strong> Run it through all k hash functions. If ALL resulting positions are 1, the element is PROBABLY in the set. If ANY position is 0, the element is DEFINITELY NOT in the set.</p><pre><code><code>Bit array (m=20), initial state:
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

Insert "alice" using 3 hash functions:
  h1("alice") = 3  -&gt; set bit 3
  h2("alice") = 9  -&gt; set bit 9
  h3("alice") = 15 -&gt; set bit 15

After inserting "alice":
[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0]

Insert "bob":
  h1("bob") = 6
  h2("bob") = 9   -&gt; already 1, leave it
  h3("bob") = 17

After inserting "bob":
[0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,1,0,0]

Check "carol":
  h1("carol") = 3  -&gt; bit is 1
  h2("carol") = 6  -&gt; bit is 1
  h3("carol") = 9  -&gt; bit is 1
All 1s -&gt; "carol" is PROBABLY in the set

But we never added "carol". Those bits were set by "alice" and "bob".
This is a FALSE POSITIVE.

Check "dave":
  h1("dave") = 2   -&gt; bit is 0
Immediately return: "dave" is DEFINITELY NOT in the set.
</code></code></pre><p>The key observation about &#8220;carol&#8221; is that three different elements (&#8221;alice&#8221; contributed bits 3 and 9, &#8220;bob&#8221; contributed bits 6 and 9) happened to collectively set all three bits that &#8220;carol&#8221; would hash to. This is the fundamental mechanism behind false positives.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-L-A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-L-A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 424w, https://substackcdn.com/image/fetch/$s_!-L-A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 848w, https://substackcdn.com/image/fetch/$s_!-L-A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 1272w, https://substackcdn.com/image/fetch/$s_!-L-A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-L-A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png" width="1456" height="791" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:791,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1881569,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-L-A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 424w, https://substackcdn.com/image/fetch/$s_!-L-A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 848w, https://substackcdn.com/image/fetch/$s_!-L-A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 1272w, https://substackcdn.com/image/fetch/$s_!-L-A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b243b25-9530-4018-9ece-e493a39e25ab_1624x882.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><h2><strong>Asymmetrical Certainty: The Most Important Property</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wq2c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wq2c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 424w, https://substackcdn.com/image/fetch/$s_!wq2c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 848w, https://substackcdn.com/image/fetch/$s_!wq2c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 1272w, https://substackcdn.com/image/fetch/$s_!wq2c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wq2c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png" width="1456" height="807" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:807,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1473582,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wq2c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 424w, https://substackcdn.com/image/fetch/$s_!wq2c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 848w, https://substackcdn.com/image/fetch/$s_!wq2c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 1272w, https://substackcdn.com/image/fetch/$s_!wq2c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b4d5713-dee3-4db6-8f7a-5161d65c5dda_1534x850.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is the most widely misunderstood property of Bloom filters, and getting it right changes how you think about using them.</p><p><strong>The filter has a zero percent false negative rate. Always. Without exception.</strong></p><p>When you add an element, you set specific bits. Those bits stay set. They are never cleared in a standard Bloom filter. So when you later query for that element, the hash functions will compute the same positions, and every one of those bits will still be 1. The query will always return &#8220;probably present&#8221; for any element that was actually inserted. This is a mathematical guarantee, not a probabilistic one.</p><p><strong>The &#8220;probably&#8221; only applies to yes answers, never to no answers.</strong></p><p>When a Bloom filter returns &#8220;definitely not present,&#8221; trust it completely. That result is 100% accurate. The bit it found was 0, which means no element that was ever inserted mapped to that position through that hash function. There is no way for a true member to have left a 0 bit behind.</p><p>When a Bloom filter returns &#8220;probably present,&#8221; treat that as a hint, not a guarantee. You may need to verify with an exact lookup if the cost of acting on a false positive is significant.</p><p>This asymmetry is precisely what makes Bloom filters useful. Most systems care much more about missing a true member (false negative) than occasionally checking a non-member (false positive). A web crawler that misses a URL it already visited will crawl it again, which is expensive. A browser that occasionally double-checks a safe URL against a remote server is just slightly slower. The Bloom filter&#8217;s guarantee eliminates the expensive case entirely.</p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2><strong>The Mathematics Behind Bloom Filters</strong></h2><p>Understanding the math lets you build Bloom filters that are actually optimal rather than guessing at parameters.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BF39!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BF39!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 424w, https://substackcdn.com/image/fetch/$s_!BF39!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 848w, https://substackcdn.com/image/fetch/$s_!BF39!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 1272w, https://substackcdn.com/image/fetch/$s_!BF39!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BF39!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png" width="1456" height="811" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:811,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1613435,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BF39!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 424w, https://substackcdn.com/image/fetch/$s_!BF39!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 848w, https://substackcdn.com/image/fetch/$s_!BF39!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 1272w, https://substackcdn.com/image/fetch/$s_!BF39!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ecda6e3-e324-4991-a5c0-332a1f3a0276_1580x880.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>False Positive Probability</strong></h3><p>With a bit array of size m, k hash functions, and n elements already inserted, the probability that any given bit is still 0 after all insertions is:</p><pre><code><code>P(bit = 0) = (1 - 1/m)^(kn) &#8776; e^(-kn/m)
</code></code></pre><p>The false positive probability, which requires that all k positions for a new element are already set to 1, is:</p><pre><code><code>P(false positive) = (1 - e^(-kn/m))^k
</code></code></pre><p>In practice, this means:</p><pre><code><code>m=1,000,000 bits (122 KB), n=100,000 elements, k=7 hash functions:
  P(false positive) &#8776; 0.008 = about 1%

m=10,000,000 bits (1.2 MB), n=100,000 elements, k=7:
  P(false positive) &#8776; 0.0000001 = one in 10 million

m=10,000,000 bits (1.2 MB), n=1,000,000 elements, k=7:
  P(false positive) &#8776; 0.018 = about 2%
</code></code></pre><p>The false positive rate rises as the filter fills. Design for your expected maximum element count.</p><h3><strong>The 50% Sweet Spot</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3ouB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3ouB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 424w, https://substackcdn.com/image/fetch/$s_!3ouB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 848w, https://substackcdn.com/image/fetch/$s_!3ouB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 1272w, https://substackcdn.com/image/fetch/$s_!3ouB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3ouB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png" width="1456" height="776" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:776,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1434769,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3ouB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 424w, https://substackcdn.com/image/fetch/$s_!3ouB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 848w, https://substackcdn.com/image/fetch/$s_!3ouB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 1272w, https://substackcdn.com/image/fetch/$s_!3ouB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4920419a-6248-4ea4-ba12-c226125f5ee8_1546x824.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Here is a fact most explanations skip: <strong>a Bloom filter operates at its absolute maximum efficiency when exactly half the bits in the array are 1 and half are 0</strong>.</p><p>When the bit array looks completely random, half zeros and half ones, the probability that any given bit is 0 is exactly 0.5. The false positive probability becomes (0.5)^k. For k=10 hash functions, that is one in 1,024. This is the theoretical minimum false positive rate for that number of hash functions.</p><p>If your filter is more than half full, you are degrading performance. If you are below half full, you could have used a smaller array and saved memory. The ideal operating point, from a pure efficiency standpoint, is the half-way mark.</p><p>This has a practical implication: monitor your Bloom filter&#8217;s fill ratio in production. When it approaches 50% occupied, the false positive rate is still at its design target. As it climbs toward 70 or 80%, false positive rates climb faster than you expect.</p><h3><strong>Optimal Parameters</strong></h3><p>Given the number of elements you expect to insert (n) and the false positive rate you can tolerate (p):</p><pre><code><code>Optimal bit array size:
  m = -n * ln(p) / (ln(2))^2

Optimal number of hash functions:
  k = (m / n) * ln(2) &#8776; 0.693 * (m/n)
</code></code></pre><p>For 1 million elements at 1% false positive rate:</p><pre><code><code>import math

n = 1_000_000
p = 0.01

m = int(-n * math.log(p) / (math.log(2) ** 2))
k = round((m / n) * math.log(2))

print(f"Bit array size: {m:,} bits = {m/8/1024:.1f} KB")
print(f"Hash functions: {k}")
print(f"Space per element: {m/n:.1f} bits")
</code></code></pre><pre><code><code>Bit array size: 9,585,059 bits = 1,170.5 KB
Hash functions: 7
Space per element: 9.6 bits
</code></code></pre><p>1.2 MB to represent membership for 1 million items at 1% error. A Python set of 1 million 20-byte strings needs roughly 80 MB. That is a 60x space reduction.</p><p>For a 0.1% false positive rate: m = 14,377,589 bits, k = 10. Still under 2 MB. The space cost of achieving 10x better accuracy is just 500 KB more.</p><h3><strong>The Hash Function Count Trap</strong></h3><p>Adding more hash functions does not monotonically improve a Bloom filter. This is a subtle but important point.</p><p>More hash functions mean each insertion sets more bits, which means the bit array fills up faster. A filter with k=20 hash functions fills the array with 1s much faster than one with k=7, which means the false positive rate actually increases once the array gets crowded.</p><p>The optimal k formula balances these two effects. Too few hash functions means you are not distinguishing elements well enough. Too many means you are filling the array too fast. The optimum, as derived from calculus of the false positive formula, sits exactly at k = (m/n) * ln(2).</p><div><hr></div><h2><strong>Hash Functions: The Right Choice and the Wrong Choice</strong></h2><h3><strong>Why Cryptographic Hashes Are Wrong</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gOzd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gOzd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 424w, https://substackcdn.com/image/fetch/$s_!gOzd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 848w, https://substackcdn.com/image/fetch/$s_!gOzd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 1272w, https://substackcdn.com/image/fetch/$s_!gOzd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gOzd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png" width="302" height="321.9208443271768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:808,&quot;width&quot;:758,&quot;resizeWidth&quot;:302,&quot;bytes&quot;:635648,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gOzd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 424w, https://substackcdn.com/image/fetch/$s_!gOzd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 848w, https://substackcdn.com/image/fetch/$s_!gOzd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 1272w, https://substackcdn.com/image/fetch/$s_!gOzd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbba70a36-3bca-4fdf-a2fa-1d298b2520ba_758x808.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Many engineers instinctively reach for SHA-256 or MD5 when they need a hash function. For Bloom filters, this is a significant mistake.</p><p>Cryptographic hash functions are designed to be computationally expensive. That slowness is a feature for security (it makes brute-force attacks hard), but it is a fatal flaw for a data structure that may be called millions of times per second. SHA-256 computes at roughly 100 to 200 MB/s on typical hardware. MurmurHash3 runs at 3 to 5 GB/s, which is 20 to 50 times faster.</p><p>For a Bloom filter checking 1 million queries per second with k=7 hash functions, the difference between SHA-256 and MurmurHash3 is the difference between a server that maxes out at 15% CPU and one that is completely saturated.</p><h3><strong>The Two-Hash Trick</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SgKp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SgKp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 424w, https://substackcdn.com/image/fetch/$s_!SgKp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 848w, https://substackcdn.com/image/fetch/$s_!SgKp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 1272w, https://substackcdn.com/image/fetch/$s_!SgKp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SgKp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png" width="308" height="341.02949061662196" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:826,&quot;width&quot;:746,&quot;resizeWidth&quot;:308,&quot;bytes&quot;:678807,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SgKp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 424w, https://substackcdn.com/image/fetch/$s_!SgKp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 848w, https://substackcdn.com/image/fetch/$s_!SgKp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 1272w, https://substackcdn.com/image/fetch/$s_!SgKp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec1aa1a0-caa9-49bd-9133-fd116aab073a_746x826.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Here is the clever part: you do not actually need k independent hash functions. You only need two.</p><p>The mathematical insight, proven by Kirsch and Mitzenmacher in 2006, is that you can simulate k independent hash functions by taking linear combinations of just two base hash values:</p><pre><code><code>g_i(x) = h1(x) + i * h2(x)  for i = 0, 1, 2, ..., k-1
</code></code></pre><p>This produces k different positions from just two actual hash computations. The false positive rate is asymptotically the same as using k truly independent hash functions.</p><pre><code><code>import mmh3  # pip install mmh3 -- MurmurHash3 Python binding

def get_positions(item, m, k):
    """Generate k bit positions from two base hashes using the Kirsch-Mitzenmacher trick."""
    item_bytes = item.encode('utf-8')
    
    # Two base hashes using different seeds
    h1 = mmh3.hash(item_bytes, seed=0, signed=False)
    h2 = mmh3.hash(item_bytes, seed=1, signed=False)
    
    # Simulate k hash functions through linear combination
    return [(h1 + i * h2) % m for i in range(k)]
</code></code></pre><p>This reduces the actual hash computation cost from k cryptographic calls to two fast non-cryptographic calls, with no meaningful loss in quality.</p><h3><strong>Production Hash Function Choices</strong></h3><p><strong>MurmurHash3</strong> is the standard. Extremely fast, excellent distribution, not cryptographically secure (which you do not need). Used in Cassandra, Redis, Elasticsearch, and most production Bloom filter implementations.</p><p><strong>xxHash</strong> is another strong choice, slightly faster than MurmurHash3 on some architectures.</p><p><strong>FNV (Fowler-Noll-Vo)</strong> is simpler to implement and fast, though slightly weaker distribution than MurmurHash3 for some input patterns.</p><p>Avoid: MD5, SHA-1, SHA-256, bcrypt, or any hash designed for security rather than speed.</p><div><hr></div><h2><strong>A Complete Implementation</strong></h2><pre><code><code>import math
import mmh3

class BloomFilter:
    def __init__(self, expected_elements: int, false_positive_rate: float):
        self.n = expected_elements
        self.p = false_positive_rate
        
        # Calculate optimal parameters
        self.m = int(-expected_elements * math.log(false_positive_rate)
                     / (math.log(2) ** 2))
        self.k = max(1, round((self.m / expected_elements) * math.log(2)))
        
        # Allocate bit array as bytearray (8 bits per byte)
        self.bits = bytearray(math.ceil(self.m / 8))
        self.count = 0
        
        print(f"Bloom filter: {self.m:,} bits ({self.m/8/1024:.1f} KB), "
              f"k={self.k} hash functions, "
              f"target FP rate: {self.p:.3%}")

    def _positions(self, item: str):
        """Generate k bit positions using the two-hash trick."""
        item_bytes = item.encode('utf-8')
        h1 = mmh3.hash(item_bytes, seed=0, signed=False)
        h2 = mmh3.hash(item_bytes, seed=1, signed=False)
        return [(h1 + i * h2) % self.m for i in range(self.k)]

    def add(self, item: str):
        for pos in self._positions(item):
            self.bits[pos &gt;&gt; 3] |= (1 &lt;&lt; (pos &amp; 7))  # set bit
        self.count += 1

    def contains(self, item: str) -&gt; bool:
        return all(
            self.bits[pos &gt;&gt; 3] &amp; (1 &lt;&lt; (pos &amp; 7))
            for pos in self._positions(item)
        )
    
    @property
    def fill_ratio(self) -&gt; float:
        """Fraction of bits set to 1. Optimal at 0.5."""
        return sum(bin(byte).count('1') for byte in self.bits) / self.m
    
    @property
    def estimated_fpr(self) -&gt; float:
        """Current estimated false positive rate based on fill."""
        return (1 - math.e ** (-self.k * self.count / self.m)) ** self.k
</code></code></pre><div><hr></div><h2><strong>The Deletion Problem: A Deep Dive</strong></h2><p>The inability to delete elements from a standard Bloom filter is one of the most misunderstood properties, and there is more nuance here than most explanations provide.</p><p><strong>Why deletion breaks a standard Bloom filter.</strong> When you set a bit to 1 during insertion, you do not know which elements contributed to that bit. Multiple elements may have hashed to the same position. If you flip a bit from 1 to 0 to delete one element, you may be destroying the evidence for other elements that also hash to that position. Those elements would then return false negatives, which violates the core guarantee.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0cXO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0cXO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 424w, https://substackcdn.com/image/fetch/$s_!0cXO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 848w, https://substackcdn.com/image/fetch/$s_!0cXO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 1272w, https://substackcdn.com/image/fetch/$s_!0cXO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0cXO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png" width="1456" height="773" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:773,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1620030,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0cXO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 424w, https://substackcdn.com/image/fetch/$s_!0cXO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 848w, https://substackcdn.com/image/fetch/$s_!0cXO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 1272w, https://substackcdn.com/image/fetch/$s_!0cXO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb671018a-4e08-4971-b5ec-c98ff58f45ef_1582x840.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Counting Bloom Filters</strong> solve this by replacing each 1-bit with a small integer counter (typically 4 bits, allowing counts from 0 to 15):</p><pre><code><code>Standard bit:   0 or 1
Counting slot:  0, 1, 2, 3, ... up to 15 (4-bit counter)

Insertion: increment all k counters
Deletion:  decrement all k counters
Present:   all k counters are non-zero
</code></code></pre><p>Deletion is now safe because decrementing a counter to 0 only happens when no other element contributes to that slot. Other elements that share the slot keep their counter non-zero.</p><p>The tradeoff: 4 bits per slot instead of 1 bit per slot = 4x memory overhead. Counter overflow (16 or more elements hashing to the same slot) is theoretically possible but practically rare with good hash functions.</p><p><strong>Deletable Bloom Filters</strong> take a different approach. They divide the bit array into regions and maintain an auxiliary bit array that tracks which positions have experienced a collision (multiple elements mapping to the same bit). Safe deletion is only allowed for positions that have never experienced a collision. Positions flagged as &#8220;collision-experienced&#8221; are never cleared.</p><p>This provides more selective deletion capability without the full 4x memory overhead of counting filters. The tradeoff is that not all deletions are guaranteed to succeed.</p><p><strong>Quotient filters</strong> are a more modern alternative that supports deletion with similar memory footprint to a standard Bloom filter, achieved through a different internal structure based on quotienting. They are harder to implement but increasingly used in databases where deletion support is needed.</p><p>For use cases involving session expiry, time-windowed membership (events from the last hour), or user-specific data that needs to be removed, Counting Bloom Filters are the standard choice. The 4x memory penalty is typically acceptable given the functionality gained.</p><div><hr></div><h2><strong>Dynamic Resizing: The Hidden Constraint</strong></h2><p>Another property that surprises engineers: <strong>Bloom filters cannot be resized in place</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4vEC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4vEC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 424w, https://substackcdn.com/image/fetch/$s_!4vEC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 848w, https://substackcdn.com/image/fetch/$s_!4vEC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 1272w, https://substackcdn.com/image/fetch/$s_!4vEC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4vEC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png" width="1456" height="780" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:780,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1515208,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4vEC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 424w, https://substackcdn.com/image/fetch/$s_!4vEC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 848w, https://substackcdn.com/image/fetch/$s_!4vEC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 1272w, https://substackcdn.com/image/fetch/$s_!4vEC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ed2c0bc-7c3b-4cc6-8b8b-f75aab748e75_1550x830.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is not a limitation of specific implementations. It is a mathematical property of the structure. The hash functions produce positions in the range [0, m-1] using a modulo operation tied to the specific array size m. If you change m, you change which positions every element maps to. A vector that hashed to positions 3, 9, 15 in an array of size 20 will hash to completely different positions in an array of size 40.</p><p>There is no efficient migration path. You cannot copy the existing bits into a larger array and continue. You must:</p><ol><li><p>Create a new, larger Bloom filter from scratch</p></li><li><p>Access your source-of-truth database (which the Bloom filter was designed to avoid)</p></li><li><p>Re-insert every element into the new filter</p></li><li><p>Swap out the old filter for the new one</p></li></ol><p>This means you must <strong>estimate your element count before building the filter</strong>. Size for your expected maximum, not your current count. If you plan to grow from 100K to 10M elements over the next year, build for 10M from the start.</p><p>The practical consequence: Bloom filter capacity planning is permanent. Get the sizing wrong at creation time, and you either operate with a degraded false positive rate (if underpowered) or waste memory (if overprovisioned).</p><p><strong>Scalable Bloom Filters</strong> solve this architectural problem by chaining multiple filters:</p><pre><code><code>Filter 1: p=0.01,  capacity=100,000 elements -&gt; full
Filter 2: p=0.005, capacity=200,000 elements -&gt; full
Filter 3: p=0.0025,capacity=400,000 elements -&gt; currently active
</code></code></pre><p>When the current filter approaches capacity, a new filter is created with tighter false positive rate and larger capacity (typically 2x). Elements are added only to the latest filter. Lookup checks all filters in the chain.</p><p>The mathematical property that makes this work: the false positive rates of a geometric series of filters sum to a bounded total. If each new filter has a false positive rate half of the previous one, the total chain false positive rate converges to twice the initial rate, regardless of how many filters you chain.</p><p>Memory grows proportionally to actual element count rather than the maximum capacity you pre-allocated. This is the correct choice for applications with genuinely unpredictable growth.</p><div><hr></div><h2><strong>Advanced Variants You Should Know</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jRZ9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jRZ9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 424w, https://substackcdn.com/image/fetch/$s_!jRZ9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 848w, https://substackcdn.com/image/fetch/$s_!jRZ9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 1272w, https://substackcdn.com/image/fetch/$s_!jRZ9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jRZ9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png" width="636" height="322" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/49c3c05f-d959-4450-acbc-6683f6283201_636x322.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:322,&quot;width&quot;:636,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:309071,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jRZ9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 424w, https://substackcdn.com/image/fetch/$s_!jRZ9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 848w, https://substackcdn.com/image/fetch/$s_!jRZ9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 1272w, https://substackcdn.com/image/fetch/$s_!jRZ9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49c3c05f-d959-4450-acbc-6683f6283201_636x322.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Invertible Bloom Filters</strong> go further than any variant discussed so far. A standard Bloom filter can only tell you whether an element is probably in the set. An invertible filter lets you actually recover and list all the elements that were inserted. It achieves this through a structure borrowed from linear algebra: each slot stores an XOR of all keys that hash to it plus a count. Under certain conditions, you can iteratively &#8220;peel&#8221; singletons from the structure to recover all elements. Used for set reconciliation between distributed systems.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iT9_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iT9_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 424w, https://substackcdn.com/image/fetch/$s_!iT9_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 848w, https://substackcdn.com/image/fetch/$s_!iT9_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 1272w, https://substackcdn.com/image/fetch/$s_!iT9_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iT9_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png" width="630" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:362,&quot;width&quot;:630,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:326758,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iT9_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 424w, https://substackcdn.com/image/fetch/$s_!iT9_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 848w, https://substackcdn.com/image/fetch/$s_!iT9_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 1272w, https://substackcdn.com/image/fetch/$s_!iT9_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99100ecd-c62b-4d83-b24a-49b6aef663c9_630x362.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Compressed Bloom Filters</strong> address the case where you need to transfer a Bloom filter over a network, such as from a central server to clients or between distributed nodes. A 100 MB Bloom filter can be compressed to 30 to 50 MB with standard LZ4 compression without any loss of accuracy, because the bit array that is approximately half 0s and half 1s compresses well. Compressed Bloom filters are the variant Google uses to distribute safe-browsing filter updates to Chrome.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UCWX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UCWX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 424w, https://substackcdn.com/image/fetch/$s_!UCWX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 848w, https://substackcdn.com/image/fetch/$s_!UCWX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 1272w, https://substackcdn.com/image/fetch/$s_!UCWX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UCWX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png" width="610" height="331.0365853658537" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:356,&quot;width&quot;:656,&quot;resizeWidth&quot;:610,&quot;bytes&quot;:359780,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UCWX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 424w, https://substackcdn.com/image/fetch/$s_!UCWX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 848w, https://substackcdn.com/image/fetch/$s_!UCWX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 1272w, https://substackcdn.com/image/fetch/$s_!UCWX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8151a958-0cdf-4fe9-a6cf-d0c7a73d3440_656x356.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Partitioned Bloom Filters</strong> divide the bit array into k equal segments and assign each hash function exclusively to one segment. This prevents any two hash functions from writing to the same region, which slightly improves the distribution properties in some workloads and makes parallel multi-threaded operations easier to implement safely.</p><p><strong>Xor Filters (Graf and Lemire, 2019)</strong> are the modern alternative for static datasets. Instead of setting multiple bits, they store XOR-based fingerprints in a three-level structure. They achieve the same membership query properties as Bloom filters but use approximately 15% less memory and require only 3 memory accesses per query versus k accesses.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!crqN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!crqN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 424w, https://substackcdn.com/image/fetch/$s_!crqN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 848w, https://substackcdn.com/image/fetch/$s_!crqN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 1272w, https://substackcdn.com/image/fetch/$s_!crqN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!crqN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png" width="586" height="294.73372781065086" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:340,&quot;width&quot;:676,&quot;resizeWidth&quot;:586,&quot;bytes&quot;:311544,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!crqN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 424w, https://substackcdn.com/image/fetch/$s_!crqN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 848w, https://substackcdn.com/image/fetch/$s_!crqN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 1272w, https://substackcdn.com/image/fetch/$s_!crqN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6ad22308-6a7f-4552-8aae-69981a1a4dc0_676x340.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The critical limitation: Xor filters are static. You build them over a fixed dataset and cannot add elements afterward. They are ideal for immutable datasets: a complete list of banned IP addresses, all valid product SKUs in a catalog, a fixed set of known malicious file hashes.</p><p><strong>Fuse filters (Dietzfelbinger and Walzer, 2019)</strong> are similar to Xor filters with even faster construction time. Both are increasingly used in database systems for read-only filter layers.</p><div><hr></div><h2><strong>Real-World Uses: Where Bloom Filters Run Right Now</strong></h2><h3><strong>Database Engines: Eliminating Ghost Reads</strong></h3><p>The most widespread use of Bloom filters in production systems today is inside storage engines. Apache Cassandra, HBase, BigTable, RocksDB, and LevelDB all use them for the same purpose.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fw-K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fw-K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 424w, https://substackcdn.com/image/fetch/$s_!fw-K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 848w, https://substackcdn.com/image/fetch/$s_!fw-K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 1272w, https://substackcdn.com/image/fetch/$s_!fw-K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fw-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png" width="1456" height="697" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:697,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1287635,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fw-K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 424w, https://substackcdn.com/image/fetch/$s_!fw-K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 848w, https://substackcdn.com/image/fetch/$s_!fw-K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 1272w, https://substackcdn.com/image/fetch/$s_!fw-K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa3af87a-4459-4fcf-aabb-227dad93191d_1530x732.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>LSM-tree-based databases like RocksDB store data in immutable SSTables. When you query for a key, the system must search multiple SSTables to find the current value. Many queries ask for keys that do not exist at all. Without Bloom filters, these &#8220;ghost reads&#8221; require touching every SSTable on disk, which is expensive.</p><p>Each SSTable maintains a Bloom filter of all the keys it contains. Before reading an SSTable from disk, the engine checks the filter. If the filter returns &#8220;definitely not present,&#8221; the SSTable is skipped entirely. For a database serving many small queries where most reads are for non-existent keys (common in time-series data, event logs, and user activity tracking), Bloom filters eliminate the large majority of disk I/O.</p><p>Cassandra&#8217;s SSTables typically use 1 to 5% false positive rates. This adds negligible memory overhead (roughly 10 bits per key) while eliminating the vast majority of unnecessary disk seeks.</p><h3><strong>Google Chrome: Safe Browsing Without Downloading the List</strong></h3><p>Chrome&#8217;s Safe Browsing feature needs to warn you when you are about to visit a known phishing or malware site. The complete list of malicious URLs contains hundreds of millions of entries and would require 50 to 100 MB to transmit and store on every device.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nX2n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nX2n!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 424w, https://substackcdn.com/image/fetch/$s_!nX2n!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 848w, https://substackcdn.com/image/fetch/$s_!nX2n!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 1272w, https://substackcdn.com/image/fetch/$s_!nX2n!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nX2n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png" width="1456" height="691" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:691,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1248714,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nX2n!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 424w, https://substackcdn.com/image/fetch/$s_!nX2n!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 848w, https://substackcdn.com/image/fetch/$s_!nX2n!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 1272w, https://substackcdn.com/image/fetch/$s_!nX2n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F945ba2ce-2ecc-4e66-b347-8bdafc4eb392_1568x744.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Instead, Google distributes a Bloom filter of the dangerous URLs. This compressed representation fits in roughly 1 to 5 MB and is downloaded incrementally. When Chrome navigates to a URL, it checks the local Bloom filter first. If the filter returns &#8220;definitely not present,&#8221; Chrome proceeds normally with no network call. If the filter returns &#8220;probably present,&#8221; Chrome makes a single API call to Google to verify whether this is a true positive before showing the warning.</p><p>This architecture means the vast majority of browsing requires zero network lookups for safety checking, the filter updates propagate efficiently, and Google does not learn which specific URLs each user visits through the filter mechanism.</p><h3><strong>Facebook and Akamai: Preventing Cache &#8220;One-Hit Wonders&#8221;</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mq32!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mq32!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 424w, https://substackcdn.com/image/fetch/$s_!mq32!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 848w, https://substackcdn.com/image/fetch/$s_!mq32!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 1272w, https://substackcdn.com/image/fetch/$s_!mq32!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mq32!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png" width="1456" height="553" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/caf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:553,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1019472,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mq32!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 424w, https://substackcdn.com/image/fetch/$s_!mq32!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 848w, https://substackcdn.com/image/fetch/$s_!mq32!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 1272w, https://substackcdn.com/image/fetch/$s_!mq32!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcaf93750-040a-4903-afc3-eaed9ab97d1b_1538x584.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A one-hit wonder in caching terminology is content that a user requests exactly once and never again. If you immediately cache content on the first request, you are burning expensive cache space on data that will never be accessed a second time, displacing genuinely popular content.</p><p>Facebook&#8217;s feed and Akamai&#8217;s CDN both use Bloom filters to solve this. The logic is:</p><ol><li><p>User requests a piece of content for the first time</p></li><li><p>Record the request in a Bloom filter (do not cache yet)</p></li><li><p>User requests the same content a second time</p></li><li><p>Bloom filter returns &#8220;probably present&#8221; (this is the second visit)</p></li><li><p>Now cache the content, since it has demonstrated repeat interest</p></li></ol><p>The false positive rate is not a problem here. A false positive means caching something after a single visit that looks like a second visit due to hash collision. That is slightly suboptimal but acceptable. The false negative guarantee means that anything that genuinely visited twice will always be detected and cached.</p><p>This technique is also used in web crawlers and recommendation engines. Medium uses Bloom filters to track which articles a user has already read, so the recommendation engine never surfaces content you have already consumed.</p><h3><strong>Bitcoin: Lightweight Wallet Synchronization</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d55c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d55c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 424w, https://substackcdn.com/image/fetch/$s_!d55c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 848w, https://substackcdn.com/image/fetch/$s_!d55c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 1272w, https://substackcdn.com/image/fetch/$s_!d55c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!d55c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png" width="1456" height="777" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:777,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1416563,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!d55c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 424w, https://substackcdn.com/image/fetch/$s_!d55c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 848w, https://substackcdn.com/image/fetch/$s_!d55c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 1272w, https://substackcdn.com/image/fetch/$s_!d55c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe3217771-d933-4ac5-b083-97ba3e79b3ef_1540x822.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Bitcoin&#8217;s Simplified Payment Verification (SPV) is one of the more creative applications. A lightweight mobile wallet cannot download the entire blockchain (currently over 500 GB). But it needs to know which transactions are relevant to its addresses.</p><p>The wallet creates a Bloom filter of its own addresses and sends it to a full node. The full node uses the filter to decide which transactions to transmit. Transactions whose addresses are in the filter get sent. Transactions that are definitely not relevant get dropped.</p><p>The privacy property is subtle but important. The full node does not know exactly which addresses the wallet is tracking. It only knows a probabilistic set that may include false positive addresses. This provides a weak but non-zero level of privacy protection compared to the wallet broadcasting exactly which addresses it owns.</p><h3><strong>Web Crawlers: Tracking Visited URLs at Scale</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2iuw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2iuw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 424w, https://substackcdn.com/image/fetch/$s_!2iuw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 848w, https://substackcdn.com/image/fetch/$s_!2iuw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 1272w, https://substackcdn.com/image/fetch/$s_!2iuw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2iuw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png" width="1456" height="817" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:817,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1231576,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2iuw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 424w, https://substackcdn.com/image/fetch/$s_!2iuw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 848w, https://substackcdn.com/image/fetch/$s_!2iuw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 1272w, https://substackcdn.com/image/fetch/$s_!2iuw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cdd3e92-f84b-45ae-b5a1-86459e51e710_1472x826.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Google&#8217;s web crawler encounters billions of URLs. Every time it discovers a link, it needs to know whether it has already crawled that URL. Storing all visited URLs in a hash set would require hundreds of gigabytes of RAM.</p><p>A Bloom filter holds the footprint of every visited URL in roughly 10 to 15 bytes per URL rather than the full URL itself (which averages 50 to 100 bytes including overhead). At 10 billion visited URLs, that is the difference between 100 to 150 GB (hash set) and 10 to 15 GB (Bloom filter).</p><p>The false positive rate is acceptable: occasionally recrawling a page that the filter mistakenly reports as already visited is a minor inefficiency. Missing a page the filter guarantees has not been visited is impossible, so no page goes uncrawled due to a false negative.</p><h3><strong>Network Security: DDoS Mitigation and IP Filtering</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pUFk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pUFk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 424w, https://substackcdn.com/image/fetch/$s_!pUFk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 848w, https://substackcdn.com/image/fetch/$s_!pUFk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 1272w, https://substackcdn.com/image/fetch/$s_!pUFk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pUFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png" width="1456" height="773" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:773,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1822786,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pUFk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 424w, https://substackcdn.com/image/fetch/$s_!pUFk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 848w, https://substackcdn.com/image/fetch/$s_!pUFk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 1272w, https://substackcdn.com/image/fetch/$s_!pUFk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ca453b9-1685-4cf3-a083-af933657c839_1552x824.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Enterprise network routers use Bloom filters to maintain deny lists of known malicious IP addresses. Checking an incoming packet&#8217;s source IP against a Bloom filter takes nanoseconds. The same check against a traditional database takes milliseconds, which is unusable at network routing speeds.</p><p>For DDoS mitigation, routers maintain a Bloom filter of IP addresses that have recently sent malicious traffic. Every incoming packet is checked. Definitely-not-in-filter packets proceed normally. Probably-in-filter packets are routed to deeper inspection. This two-tier approach keeps packet processing fast at the common case while still catching most malicious sources.</p><h3><strong>Username and Email Validation</strong></h3><p>Platforms with massive user bases (Instagram, Twitter, Gmail) use Bloom filters as a fast pre-filter for registration checks. When you type a username, the system checks the Bloom filter before running any database query. If the filter returns &#8220;definitely not present,&#8221; the username is available and you can display the green checkmark immediately. If it returns &#8220;probably present,&#8221; only then does the system query the actual database.</p><p>This eliminates database queries for the common case of users typing genuinely available usernames, reducing database load significantly during high-traffic registration periods.</p><div><hr></div><h2><strong>Commonly Misunderstood Concepts</strong></h2><h3><strong>&#8220;You cannot delete from a Bloom filter&#8221;</strong></h3><p>True for standard Bloom filters. Not true as a categorical statement about Bloom filter variants. Counting Bloom Filters and Deletable Bloom Filters both support deletion, with different tradeoffs in memory and completeness. If you need deletion, use a Counting Bloom Filter.</p><h3><strong>&#8220;A high false positive rate means the filter is broken&#8221;</strong></h3><p>False positive rates rise predictably as the filter fills. A filter designed for 1% FPR at 1 million elements will show 5 to 10% FPR at 2 million elements. This is expected behavior, not a malfunction. Monitor your fill ratio. Size for your expected maximum.</p><h3><strong>&#8220;More hash functions are always better&#8221;</strong></h3><p>The optimal number of hash functions is derived mathematically and is typically between 5 and 15 for practical applications. More than that, you are filling the bit array faster than you are improving discrimination, which actually increases the false positive rate. k = (m/n) * ln(2) is the formula to use. Trust the math.</p><h3><strong>&#8220;You can resize by copying to a larger array&#8221;</strong></h3><p>You cannot. The hash function positions are tied to the array size m through the modulo operation. A full rebuild from source data is the only option. Plan your capacity before creation.</p><h3><strong>&#8220;Bloom filters have false negatives too&#8221;</strong></h3><p>They do not. If an element was inserted, it will always return &#8220;probably present&#8221; on a subsequent query. The bits it set are permanent in a standard filter. The probabilistic component applies only to elements that were never inserted.</p><h3><strong>&#8220;SHA-256 is the safest choice for hash functions&#8221;</strong></h3><p>It is safe in the cryptographic sense but completely wrong for Bloom filters. Cryptographic security has zero value here. Speed has enormous value. MurmurHash3 or xxHash runs 20 to 50 times faster than SHA-256 and produces equally well-distributed outputs for Bloom filter purposes.</p><div><hr></div><h2><strong>Sizing a Bloom Filter in Practice</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IWY8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IWY8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 424w, https://substackcdn.com/image/fetch/$s_!IWY8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 848w, https://substackcdn.com/image/fetch/$s_!IWY8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 1272w, https://substackcdn.com/image/fetch/$s_!IWY8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IWY8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png" width="1456" height="583" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:583,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1210974,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IWY8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 424w, https://substackcdn.com/image/fetch/$s_!IWY8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 848w, https://substackcdn.com/image/fetch/$s_!IWY8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 1272w, https://substackcdn.com/image/fetch/$s_!IWY8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b2f8209-af3b-4a5d-84ff-0ade6f214a5e_1534x614.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The math for choosing filter parameters is straightforward. You need two inputs: expected number of elements (n) and target false positive rate (p).</p><pre><code><code>import math

def bloom_filter_params(n, p):
    """Calculate optimal bit array size and hash function count."""
    m = -n * math.log(p) / (math.log(2) ** 2)
    k = (m / n) * math.log(2)
    return int(m), round(k)

# Real-world sizing examples
examples = [
    (100_000,       0.01),    # 100K usernames, 1% FPR
    (1_000_000,     0.01),    # 1M URLs, 1% FPR
    (10_000_000,    0.001),   # 10M passwords, 0.1% FPR
    (100_000_000,   0.0001),  # 100M items, 0.01% FPR
    (1_000_000_000, 0.01),    # 1B web pages, 1% FPR
]

print(f"{'Elements':&gt;15} {'FPR':&gt;8} {'Bits (M)':&gt;10} {'MB':&gt;8} {'k':&gt;4}")
print("-" * 47)
for n, p in examples:
    m, k = bloom_filter_params(n, p)
    print(f"{n:&gt;15,} {p:&gt;8.4f} {m/1e6:&gt;10.1f} {m/8/1e6:&gt;8.1f} {k:&gt;4}")
</code></code></pre><pre><code><code>       Elements      FPR   Bits (M)       MB    k
-----------------------------------------------
        100,000   0.0100        0.9      0.1    7
      1,000,000   0.0100        9.6      1.2    7
     10,000,000   0.0010      143.8     18.0   10
    100,000,000   0.0001     1917.0    239.6   13
  1,000,000,000   0.0100     9585.1   1198.1    7
</code></code></pre><p>1 billion items at 1% FPR fits in 1.2 GB of RAM. That same dataset stored as actual strings would require 50 to 100 GB. The space compression is between 40x and 80x.</p><p><strong>The practical rule for most applications:</strong> Start with a 1% false positive rate. If a false positive triggers a disk read that costs 10ms and you are doing 10,000 lookups per second, a 1% false positive rate causes 100 unnecessary disk reads per second. If that is acceptable, you are done. If not, halve the false positive rate (roughly doubling the memory) and recalculate. Each halving of p adds roughly one bit per element. The tradeoff is very cheap.</p><div><hr></div><h2><strong>When Not to Use Bloom Filters</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Zduh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zduh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 424w, https://substackcdn.com/image/fetch/$s_!Zduh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 848w, https://substackcdn.com/image/fetch/$s_!Zduh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 1272w, https://substackcdn.com/image/fetch/$s_!Zduh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zduh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png" width="1456" height="795" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5df5bf67-b056-4de9-8858-afca83566941_1520x830.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:795,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1596384,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/196039421?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Zduh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 424w, https://substackcdn.com/image/fetch/$s_!Zduh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 848w, https://substackcdn.com/image/fetch/$s_!Zduh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 1272w, https://substackcdn.com/image/fetch/$s_!Zduh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5df5bf67-b056-4de9-8858-afca83566941_1520x830.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>When false positives are unacceptable.</strong> If a false positive causes a wrong outcome rather than just wasted work, use a HashSet. Medical record lookup, financial transaction verification, and authentication checks all belong in exact-match structures.</p><p><strong>When you need to retrieve the stored items.</strong> A Bloom filter stores membership, not the items themselves. You cannot enumerate what is in it or retrieve an element by query.</p><p><strong>When your dataset is under about 10,000 elements.</strong> A Python set holding 10,000 items uses a few hundred kilobytes and gives exact answers. The engineering complexity of a Bloom filter is not justified at this scale.</p><p><strong>When the filter will be over-capacity.</strong> A Bloom filter loaded to twice its designed capacity has a much higher false positive rate than designed. Know your expected element count before building the filter, and use a Scalable Bloom Filter if that count is genuinely uncertain.</p><p><strong>When you need sorted or ordered access.</strong> Bloom filters provide membership testing only. They have no concept of order, rank, or range queries.</p><div><hr></div><h2><strong>Summary</strong></h2><p>A Bloom filter is a space-efficient probabilistic data structure for set membership testing built from a bit array and multiple hash functions.</p><p>Its guarantees are asymmetric by design:</p><ul><li><p><strong>Definite &#8220;no&#8221;:</strong> the element was never added. Zero false negative rate. Guaranteed. Always.</p></li><li><p><strong>Probable &#8220;yes&#8221;:</strong> the element was probably added. Small, tunable false positive rate.</p></li></ul><p>The parameters that control behavior: bit array size m, number of hash functions k, and the number of inserted elements n. The optimal formulas tell you exactly how to size for your requirements.</p><p>For deletion support, use Counting Bloom Filters. For dynamic capacity, use Scalable Bloom Filters. For static datasets, consider Xor or Fuse filters. For distributed systems needing full element recovery, investigate Invertible Bloom Filters.</p><p>The one insight that ties everything together: a Bloom filter is not a weaker hash table. It is an entirely different kind of structure that solves an entirely different kind of problem. When you need to check membership in a very large set, the cost of an unnecessary operation (disk read, database query, network call) is high, and a small false positive rate is acceptable, the Bloom filter eliminates the vast majority of expensive operations with a structure that fits in a few megabytes.</p><p>That is why it shows up everywhere from Google Chrome to Apache Cassandra to the Bitcoin network. Once you understand it, you start seeing exactly where it belongs in almost every large-scale system you work on.</p><p><strong>Note: All the images are from notebooklm or from Google Nano Banana</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Python Foundations: A Beginner’s Complete Guide to Writing Real Code]]></title><description><![CDATA[A ground-up guide focusing on the essential "new" Python, from type hinting and Pydantic validation to efficient environment management with Bun/uv.]]></description><link>https://nandigamharikrishna.substack.com/p/python-foundations-a-beginners-complete</link><guid isPermaLink="false">https://nandigamharikrishna.substack.com/p/python-foundations-a-beginners-complete</guid><dc:creator><![CDATA[Hari Krishna]]></dc:creator><pubDate>Sat, 16 May 2026 04:21:41 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!DM0X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DM0X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DM0X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 424w, https://substackcdn.com/image/fetch/$s_!DM0X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 848w, https://substackcdn.com/image/fetch/$s_!DM0X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 1272w, https://substackcdn.com/image/fetch/$s_!DM0X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DM0X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png" width="1456" height="784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:784,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1597156,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DM0X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 424w, https://substackcdn.com/image/fetch/$s_!DM0X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 848w, https://substackcdn.com/image/fetch/$s_!DM0X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 1272w, https://substackcdn.com/image/fetch/$s_!DM0X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1b542ff-554c-4f73-8c2d-81dfc67a7ace_1612x868.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>If you have been putting off learning Python because it feels overwhelming, this guide is for you. We are going to cover everything from the absolute basics to writing real mini projects, with actual code you can run yourself and see the output immediately. No fluff, no theory overload. Just clear explanations and working code.</p><p>By the end of this guide, you will understand variables, control flow, data structures, functions, Pythonic patterns, file handling, and you will have built three mini projects from scratch.</p><h2><strong>What will you learn?</strong></h2><ol><li><p><strong>Variables and Types</strong>: How Python stores and identifies data</p></li><li><p><strong>Type Casting</strong>: Converting between data types when needed</p></li><li><p><strong>Control Flow</strong>: Making decisions with <code>if/elif/else</code> and repeating with <code>for</code> and <code>while</code></p></li><li><p><strong>Data Structures</strong>: Lists for ordered collections, tuples for fixed data, sets for unique values, dictionaries for key value pairs</p></li><li><p><strong>Functions</strong>: Packaging logic into reusable, named blocks</p></li><li><p><strong>Pythonic Patterns</strong>: List comprehensions, lambda functions, and error handling that make your code cleaner</p></li><li><p><strong>File Handling</strong>: Reading, writing, and appending to files safely with the <code>with</code> statement</p></li><li><p><strong>Mini Projects</strong>: A calculator, a persistent to-do list, and a CSV file parser</p></li></ol><div><hr></div><h2><strong>Part 1: Variables, Data Types, and Type Casting</strong></h2><h3><strong>What is a Variable?</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PzLZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PzLZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 424w, https://substackcdn.com/image/fetch/$s_!PzLZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 848w, https://substackcdn.com/image/fetch/$s_!PzLZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 1272w, https://substackcdn.com/image/fetch/$s_!PzLZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PzLZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png" width="1066" height="564" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/feaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:564,&quot;width&quot;:1066,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:537642,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PzLZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 424w, https://substackcdn.com/image/fetch/$s_!PzLZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 848w, https://substackcdn.com/image/fetch/$s_!PzLZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 1272w, https://substackcdn.com/image/fetch/$s_!PzLZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffeaac1a8-8dbd-42e4-adb0-a5f4ba5cbc34_1066x564.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Think of a variable as a labeled box. You put something inside the box and give it a name so you can find it later. In Python, you do not need to declare what type of data will go into the box ahead of time. Python figures that out on its own.</p><pre><code><code>name = "Alice"
age = 25
height = 5.6
is_student = True

print(type(name))
print(type(age))
print(type(height))
print(type(is_student))
print(f"Name: {name}, Age: {age}, Height: {height}, Student: {is_student}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>&lt;class 'str'&gt;
&lt;class 'int'&gt;
&lt;class 'float'&gt;
&lt;class 'bool'&gt;
Name: Alice, Age: 25, Height: 5.6, Student: True
</code></code></pre><p>Python has four primary data types you will use constantly:</p><ul><li><p><strong>str</strong> (string): Any text enclosed in quotes. <code>"Alice"</code>, <code>"hello world"</code>, <code>"123"</code> are all strings.</p></li><li><p><strong>int</strong> (integer): Whole numbers without decimals. <code>25</code>, <code>100</code>, <code>0</code>, <code>-7</code> are all integers.</p></li><li><p><strong>float</strong> (floating point): Numbers with decimal points. <code>5.6</code>, <code>3.14</code>, <code>0.001</code> are floats.</p></li><li><p><strong>bool</strong> (boolean): Only two possible values, <code>True</code> or <code>False</code>. Used for conditions and flags.</p></li></ul><p>The <code>type()</code> function tells you exactly what type a variable is. This is incredibly useful when debugging or when you are not sure what kind of data you are dealing with.</p><h3><strong>Dynamic Typing</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hxBU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hxBU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 424w, https://substackcdn.com/image/fetch/$s_!hxBU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 848w, https://substackcdn.com/image/fetch/$s_!hxBU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 1272w, https://substackcdn.com/image/fetch/$s_!hxBU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hxBU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png" width="1456" height="788" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:788,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1646888,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hxBU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 424w, https://substackcdn.com/image/fetch/$s_!hxBU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 848w, https://substackcdn.com/image/fetch/$s_!hxBU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 1272w, https://substackcdn.com/image/fetch/$s_!hxBU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F66c2ffbf-c505-4508-944f-c1e5c17768d7_1574x852.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>One of Python&#8217;s most beginner friendly features is dynamic typing. You do not write <code>string name = "Alice"</code> like in Java or C++. Python looks at the value you assign and automatically determines the type. You can even reassign a variable to a completely different type later:</p><pre><code><code>x = 10        # x is an int
x = "hello"   # now x is a str, Python is fine with this
</code></code></pre><h3><strong>Type Casting</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gvgd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gvgd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 424w, https://substackcdn.com/image/fetch/$s_!gvgd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 848w, https://substackcdn.com/image/fetch/$s_!gvgd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 1272w, https://substackcdn.com/image/fetch/$s_!gvgd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gvgd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png" width="1456" height="743" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:743,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:802206,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gvgd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 424w, https://substackcdn.com/image/fetch/$s_!gvgd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 848w, https://substackcdn.com/image/fetch/$s_!gvgd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 1272w, https://substackcdn.com/image/fetch/$s_!gvgd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe89cfc10-1ba9-4e5b-a94c-5462335514f4_1516x774.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Sometimes you receive data in one format but need it in another. For example, when a user types a number into an input field, Python receives it as a string. You need to convert it to an integer before you can do math with it. This conversion is called type casting.</p><pre><code><code>x = "42"
y = int(x)
z = float(x)
b = bool(0)
b2 = bool(1)
print(f"String '42' to int: {y}, type: {type(y)}")
print(f"String '42' to float: {z}, type: {type(z)}")
print(f"bool(0): {b}")
print(f"bool(1): {b2}")
print(f"int(3.9): {int(3.9)}")
print(f"str(100): '{str(100)}'")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>String '42' to int: 42, type: &lt;class 'int'&gt;
String '42' to float: 42.0, type: &lt;class 'float'&gt;
bool(0): False
bool(1): True
int(3.9): 3
str(100): '100'
</code></code></pre><p>Notice that <code>int(3.9)</code> gives you <code>3</code>, not <code>4</code>. Python does not round up. It simply drops the decimal part. Also notice that <code>bool(0)</code> is <code>False</code> and anything non zero is <code>True</code>. This becomes very useful when you are checking whether a number exists, a list is empty, or a string has content.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-L2h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-L2h!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 424w, https://substackcdn.com/image/fetch/$s_!-L2h!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 848w, https://substackcdn.com/image/fetch/$s_!-L2h!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 1272w, https://substackcdn.com/image/fetch/$s_!-L2h!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-L2h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png" width="1456" height="783" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:783,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1730901,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-L2h!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 424w, https://substackcdn.com/image/fetch/$s_!-L2h!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 848w, https://substackcdn.com/image/fetch/$s_!-L2h!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 1272w, https://substackcdn.com/image/fetch/$s_!-L2h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e06624b-88fa-4308-9ede-dae468a8af7a_1580x850.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2><strong>Part 2: Control Flow</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bEvz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEvz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 424w, https://substackcdn.com/image/fetch/$s_!bEvz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 848w, https://substackcdn.com/image/fetch/$s_!bEvz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 1272w, https://substackcdn.com/image/fetch/$s_!bEvz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEvz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png" width="1456" height="755" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:755,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1549129,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bEvz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 424w, https://substackcdn.com/image/fetch/$s_!bEvz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 848w, https://substackcdn.com/image/fetch/$s_!bEvz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 1272w, https://substackcdn.com/image/fetch/$s_!bEvz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c93015-6c0f-4475-820f-682f1bcf44a8_1558x808.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>if / elif / else</strong></h3><p>Control flow is how your program makes decisions. The <code>if</code> statement is the foundation of all decision making in Python.</p><pre><code><code>score = 85

if score &gt;= 90:
    print("Grade: A")
elif score &gt;= 80:
    print("Grade: B")
elif score &gt;= 70:
    print("Grade: C")
else:
    print("Grade: F")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Grade: B
</code></code></pre><p>Python reads this from top to bottom. When it finds a condition that is <code>True</code>, it runs that block and skips all the rest. The <code>elif</code> (short for &#8220;else if&#8221;) lets you chain multiple conditions. The <code>else</code> at the end is a catch all that runs only if none of the conditions above were true.</p><p>One thing beginners often miss: the indentation matters enormously in Python. Everything indented under an <code>if</code> block belongs to that block. Python uses indentation instead of curly braces like other languages.</p><h3><strong>Loops:</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sFvn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sFvn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 424w, https://substackcdn.com/image/fetch/$s_!sFvn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 848w, https://substackcdn.com/image/fetch/$s_!sFvn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 1272w, https://substackcdn.com/image/fetch/$s_!sFvn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sFvn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png" width="1456" height="796" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:796,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1615911,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sFvn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 424w, https://substackcdn.com/image/fetch/$s_!sFvn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 848w, https://substackcdn.com/image/fetch/$s_!sFvn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 1272w, https://substackcdn.com/image/fetch/$s_!sFvn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8402ee82-efb7-49f9-993e-02fac46570a9_1544x844.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>for Loops</strong></h3><p>A <code>for</code> loop lets you repeat an action for each item in a collection.</p><pre><code><code>print("Counting fruits:")
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print(f"  {fruit}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Counting fruits:
  apple
  banana
  cherry
</code></code></pre><p>The loop variable <code>fruit</code> takes on each value from the list one at a time. You can name it whatever makes sense for your context. <code>for item in items</code>, <code>for name in names</code>, <code>for number in numbers</code> are all valid.</p><h3><strong>while Loops</strong></h3><p>A <code>while</code> loop keeps running as long as a condition remains <code>True</code>. It is useful when you do not know in advance how many times you need to repeat something.</p><pre><code><code>print("Countdown:")
n = 5
while n &gt; 0:
    print(f"  {n}")
    n -= 1
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Countdown:
  5
  4
  3
  2
  1
</code></code></pre><p>Be careful with <code>while</code> loops. If your condition never becomes <code>False</code>, the loop runs forever. That is called an infinite loop and it will freeze your program. Always make sure something inside the loop changes the condition so it eventually stops.</p><h3><strong>break, continue, and pass</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BRSL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BRSL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 424w, https://substackcdn.com/image/fetch/$s_!BRSL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 848w, https://substackcdn.com/image/fetch/$s_!BRSL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 1272w, https://substackcdn.com/image/fetch/$s_!BRSL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BRSL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png" width="1456" height="792" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:792,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1541323,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BRSL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 424w, https://substackcdn.com/image/fetch/$s_!BRSL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 848w, https://substackcdn.com/image/fetch/$s_!BRSL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 1272w, https://substackcdn.com/image/fetch/$s_!BRSL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffccf0c51-0ed1-4632-ad45-dca625fb0e14_1582x860.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>These three keywords give you fine grained control over your loops:</p><pre><code><code>print("Skip 3, stop at 7:")
for i in range(1, 10):
    if i == 3:
        continue
    if i == 7:
        break
    print(f"  {i}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Skip 3, stop at 7:
  1
  2
  4
  5
  6
</code></code></pre><ul><li><p><strong>continue</strong>: Skip the rest of the current iteration and jump to the next one. When <code>i == 3</code>, we skip printing it and go straight to <code>i = 4</code>.</p></li><li><p><strong>break</strong>: Exit the loop entirely. When <code>i == 7</code>, the loop stops completely. That is why <code>7</code>, <code>8</code>, and <code>9</code> never appear.</p></li><li><p><strong>pass</strong>: Does nothing. It is a placeholder when Python requires a statement syntactically but you do not want any action to happen. You will use it when stubbing out functions or empty class bodies.</p></li></ul><div><hr></div><h2><strong>Part 3: Data Structures</strong></h2><h3><strong>Lists</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KP00!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KP00!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 424w, https://substackcdn.com/image/fetch/$s_!KP00!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 848w, https://substackcdn.com/image/fetch/$s_!KP00!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 1272w, https://substackcdn.com/image/fetch/$s_!KP00!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KP00!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png" width="1456" height="848" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:848,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1528304,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KP00!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 424w, https://substackcdn.com/image/fetch/$s_!KP00!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 848w, https://substackcdn.com/image/fetch/$s_!KP00!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 1272w, https://substackcdn.com/image/fetch/$s_!KP00!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ea155bb-61e9-4354-a79e-554134be5d48_1470x856.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A list is an ordered, mutable collection. Mutable means you can change it after creating it. Lists are probably the data structure you will use most often.</p><pre><code><code>print("=== LIST ===")
nums = [10, 20, 30, 40, 50]
print(f"List: {nums}")
print(f"Index 0: {nums[0]}")
print(f"Last element: {nums[-1]}")
print(f"Slice [1:3]: {nums[1:3]}")
nums.append(60)
nums.remove(20)
print(f"After append(60) and remove(20): {nums}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== LIST ===
List: [10, 20, 30, 40, 50]
Index 0: 10
Last element: 50
Slice [1:3]: [20, 30]
After append(60) and remove(20): [10, 30, 40, 50, 60]
</code></code></pre><p>Indexing starts at <code>0</code> in Python. So <code>nums[0]</code> is the first element, <code>nums[1]</code> is the second, and so on. Negative indexing counts from the end, so <code>nums[-1]</code> always gives you the last element regardless of how long the list is.</p><p>Slicing with <code>[1:3]</code> gives you elements from index <code>1</code> up to but not including index <code>3</code>. Think of it as &#8220;start here, stop before here.&#8221;</p><h3><strong>Tuples</strong></h3><p>A tuple looks like a list but uses parentheses and is immutable (you cannot change it after creation).</p><pre><code><code>print("=== TUPLE ===")
coords = (10, 20, 30)
print(f"Tuple: {coords}")
print(f"coords[1]: {coords[1]}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== TUPLE ===
Tuple: (10, 20, 30)
coords[1]: 20
</code></code></pre><p>Use tuples when you have data that should never change, like coordinates, RGB color values, or database records. The immutability is a feature, not a limitation. It signals to anyone reading your code that this data is fixed.</p><h3><strong>Sets</strong></h3><p>A set is an unordered collection of unique values. If you add a duplicate, it simply gets ignored.</p><pre><code><code>print("=== SET ===")
colors = {"red", "green", "blue", "red"}
print(f"Set (no duplicates): {colors}")
colors.add("yellow")
print(f"After add yellow: {colors}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== SET ===
Set (no duplicates): {'blue', 'green', 'red'}
After add yellow: {'yellow', 'blue', 'green', 'red'}
</code></code></pre><p>Notice that even though we passed <code>"red"</code> twice, the set only has it once. Sets are perfect for deduplication tasks. They are also very fast at checking whether something exists in the collection because of how they are implemented internally.</p><h3><strong>Dictionaries</strong></h3><p>A dictionary stores data as key value pairs. Instead of accessing items by position number, you access them by a meaningful name (the key).</p><pre><code><code>print("=== DICTIONARY ===")
person = {"name": "Bob", "age": 30, "city": "Delhi"}
print(f"Dict: {person}")
print(f"person['name']: {person['name']}")
person["email"] = "bob@example.com"
print(f"Keys: {list(person.keys())}")
print(f"Values: {list(person.values())}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== DICTIONARY ===
Dict: {'name': 'Bob', 'age': 30, 'city': 'Delhi'}
person['name']: Bob
Keys: ['name', 'age', 'city', 'email']
Values: ['Bob', 30, 'Delhi', 'bob@example.com']
</code></code></pre><p>Dictionaries are incredibly powerful for representing structured data. A JSON response from an API? That maps directly to a Python dictionary. A row from a database? Also a dictionary. Getting comfortable with dictionaries early will save you enormous amounts of time later.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!73dZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!73dZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 424w, https://substackcdn.com/image/fetch/$s_!73dZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 848w, https://substackcdn.com/image/fetch/$s_!73dZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 1272w, https://substackcdn.com/image/fetch/$s_!73dZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!73dZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png" width="1456" height="788" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:788,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1418842,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!73dZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 424w, https://substackcdn.com/image/fetch/$s_!73dZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 848w, https://substackcdn.com/image/fetch/$s_!73dZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 1272w, https://substackcdn.com/image/fetch/$s_!73dZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d5048dc-f86e-4487-9243-567f14585a34_1560x844.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><h2><strong>Part 4: Functions</strong></h2><p>Functions let you package a piece of logic once and reuse it as many times as you need. They are the building blocks of clean, maintainable code.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MMLF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MMLF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 424w, https://substackcdn.com/image/fetch/$s_!MMLF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 848w, https://substackcdn.com/image/fetch/$s_!MMLF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 1272w, https://substackcdn.com/image/fetch/$s_!MMLF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MMLF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png" width="1456" height="757" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:757,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1243762,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MMLF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 424w, https://substackcdn.com/image/fetch/$s_!MMLF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 848w, https://substackcdn.com/image/fetch/$s_!MMLF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 1272w, https://substackcdn.com/image/fetch/$s_!MMLF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05e78829-e39b-4b9d-bfbd-f903c0498c35_1554x808.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>Defining Functions</strong></h3><pre><code><code>def greet(name, greeting="Hello"):
    return f"{greeting}, {name}!"

print(greet("Alice"))
print(greet("Bob", "Hi"))
print(greet(name="Charlie", greeting="Hey"))
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Hello, Alice!
Hi, Bob!
Hey, Charlie!
</code></code></pre><p>The <code>def</code> keyword starts a function definition. The name comes next, then parentheses with parameters. The <code>return</code> statement sends a value back to wherever the function was called from.</p><p>The <code>greeting="Hello"</code> part is a default argument. If you call <code>greet("Alice")</code> without providing a greeting, it automatically uses <code>"Hello"</code>. If you provide one, it uses that instead.</p><p>Keyword arguments like <code>greet(name="Charlie", greeting="Hey")</code> let you pass arguments by name rather than position. This makes your code more readable and lets you specify arguments in any order.</p><h3><strong>Multiple Return Values</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hJqh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hJqh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 424w, https://substackcdn.com/image/fetch/$s_!hJqh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 848w, https://substackcdn.com/image/fetch/$s_!hJqh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 1272w, https://substackcdn.com/image/fetch/$s_!hJqh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hJqh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png" width="1456" height="779" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:779,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1581633,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hJqh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 424w, https://substackcdn.com/image/fetch/$s_!hJqh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 848w, https://substackcdn.com/image/fetch/$s_!hJqh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 1272w, https://substackcdn.com/image/fetch/$s_!hJqh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6951b96b-cc41-4275-b126-274a9687fd93_1476x790.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Python functions can return multiple values at once using a technique called tuple unpacking:</p><pre><code><code>def min_max(numbers):
    return min(numbers), max(numbers)

low, high = min_max([3, 1, 9, 5, 2])
print(f"Min: {low}, Max: {high}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Min: 1, Max: 9
</code></code></pre><p>When you write <code>return min(numbers), max(numbers)</code>, Python packs both values into a tuple and returns it. Then <code>low, high = min_max(...)</code> unpacks that tuple back into two separate variables. This is cleaner than returning a list and accessing by index.</p><div><hr></div><h2><strong>Part 5: Pythonic Features</strong></h2><h3><strong>List Comprehensions</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qSnv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qSnv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 424w, https://substackcdn.com/image/fetch/$s_!qSnv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 848w, https://substackcdn.com/image/fetch/$s_!qSnv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 1272w, https://substackcdn.com/image/fetch/$s_!qSnv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qSnv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png" width="1456" height="747" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:747,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1410422,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qSnv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 424w, https://substackcdn.com/image/fetch/$s_!qSnv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 848w, https://substackcdn.com/image/fetch/$s_!qSnv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 1272w, https://substackcdn.com/image/fetch/$s_!qSnv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F102d327d-adfd-4e30-b92f-5f7d465aa4d1_1552x796.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A list comprehension is a compact, readable way to create a list from another iterable. Instead of writing a for loop that appends to a list, you can express the whole thing in one line.</p><pre><code><code>squares = [x**2 for x in range(1, 8)]
print(f"Squares: {squares}")

evens = [x for x in range(1, 20) if x % 2 == 0]
print(f"Evens: {evens}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Squares: [1, 4, 9, 16, 25, 36, 49]
Evens: [2, 4, 6, 8, 10, 12, 14, 16, 18]
</code></code></pre><p>The format is <code>[expression for item in iterable if condition]</code>. The <code>if condition</code> part is optional. Read it like English: &#8220;give me <code>x squared</code> for each <code>x</code> in the range <code>1 to 7</code>.&#8221;</p><h3><strong>Dict and Set Comprehensions</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!plyA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!plyA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 424w, https://substackcdn.com/image/fetch/$s_!plyA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 848w, https://substackcdn.com/image/fetch/$s_!plyA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 1272w, https://substackcdn.com/image/fetch/$s_!plyA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!plyA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png" width="1456" height="369" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/acd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:369,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:747163,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!plyA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 424w, https://substackcdn.com/image/fetch/$s_!plyA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 848w, https://substackcdn.com/image/fetch/$s_!plyA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 1272w, https://substackcdn.com/image/fetch/$s_!plyA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Facd4a93e-987a-4003-9961-2fd52b74e953_1562x396.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The same idea applies to dictionaries and sets:</p><pre><code><code>word_lengths = {word: len(word) for word in ["python", "is", "amazing"]}
print(f"Word lengths: {word_lengths}")

unique_squares = {x**2 for x in [-2, -1, 0, 1, 2]}
print(f"Unique squares: {unique_squares}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Word lengths: {'python': 6, 'is': 2, 'amazing': 7}
Unique squares: {0, 1, 4}
</code></code></pre><h3><strong>Lambda Functions</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-LOS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-LOS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 424w, https://substackcdn.com/image/fetch/$s_!-LOS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 848w, https://substackcdn.com/image/fetch/$s_!-LOS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 1272w, https://substackcdn.com/image/fetch/$s_!-LOS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-LOS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png" width="1456" height="352" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:352,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:838998,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-LOS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 424w, https://substackcdn.com/image/fetch/$s_!-LOS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 848w, https://substackcdn.com/image/fetch/$s_!-LOS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 1272w, https://substackcdn.com/image/fetch/$s_!-LOS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c0039fc-c71a-497e-9c8d-6ba6702966e2_1556x376.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>A lambda is a small, anonymous function you can write in a single line. You use it when you need a function for a short, specific purpose and do not want to define a full function with <code>def</code>.</p><pre><code><code>double = lambda x: x * 2
print(f"Lambda double(5): {double(5)}")

names = ["Charlie", "Alice", "Bob"]
names.sort(key=lambda n: len(n))
print(f"Sorted by length: {names}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Lambda double(5): 10
Sorted by length: ['Bob', 'Alice', 'Charlie']
</code></code></pre><p>The <code>key=lambda n: len(n)</code> tells the sort function to sort by the length of each name rather than alphabetically. Lambdas shine in situations like this where you need to define quick sorting or filtering logic on the fly.</p><h3><strong>Error Handling with try/except</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kT5o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kT5o!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 424w, https://substackcdn.com/image/fetch/$s_!kT5o!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 848w, https://substackcdn.com/image/fetch/$s_!kT5o!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 1272w, https://substackcdn.com/image/fetch/$s_!kT5o!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kT5o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png" width="1456" height="721" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d4371af6-ded5-463e-b014-3afe3202e795_1584x784.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:721,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1123308,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kT5o!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 424w, https://substackcdn.com/image/fetch/$s_!kT5o!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 848w, https://substackcdn.com/image/fetch/$s_!kT5o!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 1272w, https://substackcdn.com/image/fetch/$s_!kT5o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4371af6-ded5-463e-b014-3afe3202e795_1584x784.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Programs encounter unexpected situations all the time. A user enters text instead of a number. A file is missing. A division by zero happens. Error handling lets your program deal with these gracefully instead of crashing.</p><pre><code><code>print("Error handling:")
try:
    result = 10 / 0
except ZeroDivisionError as e:
    print(f"Caught error: {e}")
finally:
    print("This always runs")

try:
    num = int("hello")
except ValueError as e:
    print(f"Caught ValueError: {e}")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>Error handling:
Caught error: division by zero
This always runs
Caught ValueError: invalid literal for int() with base 10: 'hello'
</code></code></pre><p>The <code>try</code> block contains the code that might fail. If an error occurs, Python jumps immediately to the matching <code>except</code> block. The <code>finally</code> block runs no matter what, whether an error happened or not. It is perfect for cleanup tasks like closing a file or a database connection.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XcY1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XcY1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 424w, https://substackcdn.com/image/fetch/$s_!XcY1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 848w, https://substackcdn.com/image/fetch/$s_!XcY1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 1272w, https://substackcdn.com/image/fetch/$s_!XcY1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XcY1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png" width="1456" height="754" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:754,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1739718,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XcY1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 424w, https://substackcdn.com/image/fetch/$s_!XcY1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 848w, https://substackcdn.com/image/fetch/$s_!XcY1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 1272w, https://substackcdn.com/image/fetch/$s_!XcY1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d783693-a626-4f95-83d8-be169c9eb64a_1576x816.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Being specific with your exception types (<code>ZeroDivisionError</code>, <code>ValueError</code>) is better than catching all exceptions blindly. It makes your code clearer and prevents you from accidentally swallowing errors you did not intend to handle.</p><div><hr></div><h2><strong>Part 6: File Handling</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PqH3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PqH3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 424w, https://substackcdn.com/image/fetch/$s_!PqH3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 848w, https://substackcdn.com/image/fetch/$s_!PqH3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 1272w, https://substackcdn.com/image/fetch/$s_!PqH3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PqH3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png" width="1456" height="679" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:679,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1596743,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PqH3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 424w, https://substackcdn.com/image/fetch/$s_!PqH3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 848w, https://substackcdn.com/image/fetch/$s_!PqH3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 1272w, https://substackcdn.com/image/fetch/$s_!PqH3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71011662-b86f-4b3b-97c4-91a550f10c35_1532x714.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Reading from and writing to files is something almost every real program needs to do. Python makes this straightforward with the <code>open()</code> function.</p><pre><code><code># Writing
with open("notes.txt", "w") as f:
    f.write("Line 1: Python is great\n")
    f.write("Line 2: File handling is easy\n")
    f.write("Line 3: with statement is safe\n")

# Reading entire file
with open("notes.txt", "r") as f:
    content = f.read()
print(content)

# Reading line by line
with open("notes.txt", "r") as f:
    for i, line in enumerate(f, 1):
        print(f"  Line {i}: {line.strip()}")

# Appending
with open("notes.txt", "a") as f:
    f.write("Line 4: Appended line\n")
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>--- Reading entire file ---
Line 1: Python is great
Line 2: File handling is easy
Line 3: with statement is safe

--- Reading line by line ---
  Line 1: Line 1: Python is great
  Line 2: Line 2: File handling is easy
  Line 3: Line 3: with statement is safe

--- After appending ---
Line 1: Python is great
Line 2: File handling is easy
Line 3: with statement is safe
Line 4: Appended line
</code></code></pre><p>The <code>with</code> statement is the correct way to handle files in Python. When the <code>with</code> block exits (even if an error occurs), Python automatically closes the file for you. Without it, you would need to manually call <code>f.close()</code> and risk leaving files open if something goes wrong.</p><p>The three modes you will use most:</p><ul><li><p><code>"w"</code> (write): Creates the file if it does not exist, overwrites if it does.</p></li><li><p><code>"r"</code> (read): Opens an existing file for reading.</p></li><li><p><code>"a"</code> (append): Adds content to the end of an existing file without erasing what is there.</p></li></ul><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2><strong>Part 7: Mini Projects</strong></h2><p>Now let us put everything together and build three real, working projects.</p><div><hr></div><h3><strong>Mini Project 1: Calculator</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YWlk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YWlk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 424w, https://substackcdn.com/image/fetch/$s_!YWlk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 848w, https://substackcdn.com/image/fetch/$s_!YWlk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 1272w, https://substackcdn.com/image/fetch/$s_!YWlk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YWlk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png" width="1456" height="785" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:785,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1375280,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YWlk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 424w, https://substackcdn.com/image/fetch/$s_!YWlk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 848w, https://substackcdn.com/image/fetch/$s_!YWlk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 1272w, https://substackcdn.com/image/fetch/$s_!YWlk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69e8f62a-99b1-4373-9f5d-b402639e249a_1476x796.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code><code>def calculator(a, b):
    results = {}
    operations = ["+", "-", "*", "/"]
    
    for operation in operations:
        if operation == "+":
            results[operation] = a + b
        elif operation == "-":
            results[operation] = a - b
        elif operation == "*":
            results[operation] = a * b
        elif operation == "/":
            results[operation] = a / b if b != 0 else "Error: Division by zero"
    
    print(f"Input: a = {a}, b = {b}")
    for op, result in results.items():
        print(f"  {a} {op} {b} = {result}")

calculator(12, 4)
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== Simple Calculator ===

Input: a = 12, b = 4
  12 + 4 = 16
  12 - 4 = 8
  12 * 4 = 48
  12 / 4 = 3.0
</code></code></pre><p>This calculator uses a dictionary to store results for each operation. The ternary expression <code>a / b if b != 0 else "Error: Division by zero"</code> prevents a crash when someone tries to divide by zero. We loop through the results dictionary at the end to print everything neatly.</p><div><hr></div><h3><strong>Mini Project 2: To-Do List CLI</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QRFx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QRFx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 424w, https://substackcdn.com/image/fetch/$s_!QRFx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 848w, https://substackcdn.com/image/fetch/$s_!QRFx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 1272w, https://substackcdn.com/image/fetch/$s_!QRFx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QRFx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png" width="1456" height="747" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:747,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:894533,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QRFx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 424w, https://substackcdn.com/image/fetch/$s_!QRFx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 848w, https://substackcdn.com/image/fetch/$s_!QRFx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 1272w, https://substackcdn.com/image/fetch/$s_!QRFx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3de1c8e4-125f-4b8c-ab0b-97d87b11e2c3_1536x788.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code><code>import json, os

TODO_FILE = "todos.json"

def load_tasks():
    if os.path.exists(TODO_FILE):
        with open(TODO_FILE, "r") as f:
            return json.load(f)
    return []

def save_tasks(tasks):
    with open(TODO_FILE, "w") as f:
        json.dump(tasks, f, indent=2)

def add_task(title):
    tasks = load_tasks()
    tasks.append({"id": len(tasks) + 1, "title": title, "done": False})
    save_tasks(tasks)
    print(f"Added: '{title}'")

def complete_task(task_id):
    tasks = load_tasks()
    for task in tasks:
        if task["id"] == task_id:
            task["done"] = True
            save_tasks(tasks)
            print(f"Completed: '{task['title']}'")
            return
    print("Task not found.")

def list_tasks():
    tasks = load_tasks()
    if not tasks:
        print("No tasks yet!")
        return
    print("\nYour To-Do List:")
    for task in tasks:
        status = "[x]" if task["done"] else "[ ]"
        print(f"  {status} {task['id']}. {task['title']}")

def delete_task(task_id):
    tasks = load_tasks()
    tasks = [t for t in tasks if t["id"] != task_id]
    save_tasks(tasks)
    print(f"Deleted task {task_id}")
</code></code></pre><p><strong>Simulated usage:</strong></p><pre><code><code>add_task("Learn Python basics")
add_task("Build a calculator")
add_task("Practice file handling")
add_task("Complete mini projects")
list_tasks()
complete_task(1)
complete_task(3)
list_tasks()
delete_task(2)
list_tasks()
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== To-Do List CLI Demo ===
Added: 'Learn Python basics'
Added: 'Build a calculator'
Added: 'Practice file handling'
Added: 'Complete mini projects'

Your To-Do List:
  [ ] 1. Learn Python basics
  [ ] 2. Build a calculator
  [ ] 3. Practice file handling
  [ ] 4. Complete mini projects
Completed: 'Learn Python basics'
Completed: 'Practice file handling'

Your To-Do List:
  [x] 1. Learn Python basics
  [ ] 2. Build a calculator
  [x] 3. Practice file handling
  [ ] 4. Complete mini projects
Deleted task 2

Your To-Do List:
  [x] 1. Learn Python basics
  [x] 3. Practice file handling
  [ ] 4. Complete mini projects
</code></code></pre><p>This project combines almost everything we learned. Tasks are stored as a list of dictionaries and saved to a JSON file so they persist between runs. The <code>delete_task</code> function uses a list comprehension to filter out the task with the matching ID. This is a real pattern you will see in production code.</p><div><hr></div><h3><strong>Mini Project 3: File Parser</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!deod!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!deod!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 424w, https://substackcdn.com/image/fetch/$s_!deod!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 848w, https://substackcdn.com/image/fetch/$s_!deod!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 1272w, https://substackcdn.com/image/fetch/$s_!deod!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!deod!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png" width="1456" height="750" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:750,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:925938,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!deod!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 424w, https://substackcdn.com/image/fetch/$s_!deod!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 848w, https://substackcdn.com/image/fetch/$s_!deod!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 1272w, https://substackcdn.com/image/fetch/$s_!deod!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd72267c1-ac80-4841-b78f-9cfa265ec62a_1534x790.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code><code>def parse_csv(filepath):
    results = []
    with open(filepath, "r") as f:
        lines = f.readlines()
    
    headers = lines[0].strip().split(",")
    
    for line in lines[1:]:
        if line.strip():
            values = line.strip().split(",")
            record = {headers[i]: values[i] for i in range(len(headers))}
            results.append(record)
    
    return results

def analyze(data):
    scores = [int(r["score"]) for r in data]
    ages = [int(r["age"]) for r in data]
    
    print(f"Total records   : {len(data)}")
    print(f"Average score   : {sum(scores)/len(scores):.1f}")
    print(f"Highest score   : {max(scores)}")
    print(f"Lowest score    : {min(scores)}")
    print(f"Average age     : {sum(ages)/len(ages):.1f}")
    
    top = max(data, key=lambda r: int(r["score"]))
    print(f"\nTop performer   : {top['name']} from {top['city']} with score {top['score']}")
    
    passed = [r for r in data if int(r["score"]) &gt;= 75]
    print(f"Passed (&gt;=75)   : {[r['name'] for r in passed]}")
</code></code></pre><p><strong>Sample CSV file:</strong></p><pre><code><code>name,age,score,city
Alice,23,88,Mumbai
Bob,30,72,Delhi
Charlie,25,95,Bangalore
Diana,28,61,Chennai
Eve,22,89,Hyderabad
Frank,35,77,Pune
</code></code></pre><p><strong>Output:</strong></p><pre><code><code>=== File Parser Demo ===

Parsed Records:
  {'name': 'Alice', 'age': '23', 'score': '88', 'city': 'Mumbai'}
  {'name': 'Bob', 'age': '30', 'score': '72', 'city': 'Delhi'}
  {'name': 'Charlie', 'age': '25', 'score': '95', 'city': 'Bangalore'}
  {'name': 'Diana', 'age': '28', 'score': '61', 'city': 'Chennai'}
  {'name': 'Eve', 'age': '22', 'score': '89', 'city': 'Hyderabad'}
  {'name': 'Frank', 'age': '35', 'score': '77', 'city': 'Pune'}

Total records   : 6
Average score   : 80.3
Highest score   : 95
Lowest score    : 61
Average age     : 27.2

Top performer   : Charlie from Bangalore with score 95
Passed (&gt;=75)   : ['Alice', 'Charlie', 'Eve', 'Frank']
</code></code></pre><p>The parser reads the first line as headers, then uses a dict comprehension inside a loop to turn each subsequent line into a properly labeled dictionary. The analysis functions use list comprehensions to extract just the scores or ages and then apply built in functions like <code>max()</code>, <code>min()</code>, and <code>sum()</code>. The <code>max(data, key=lambda r: int(r["score"]))</code> line finds the person with the highest score by using a lambda as the comparison key.</p><div><hr></div><p><strong>Conclusion</strong>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IR0W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IR0W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 424w, https://substackcdn.com/image/fetch/$s_!IR0W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 848w, https://substackcdn.com/image/fetch/$s_!IR0W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 1272w, https://substackcdn.com/image/fetch/$s_!IR0W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IR0W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png" width="1456" height="763" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:763,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1387609,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/197891060?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IR0W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 424w, https://substackcdn.com/image/fetch/$s_!IR0W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 848w, https://substackcdn.com/image/fetch/$s_!IR0W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 1272w, https://substackcdn.com/image/fetch/$s_!IR0W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e642c9b-1328-4529-a85c-378bebf6e6fd_1554x814.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The most important next step is to build something. Pick one of the mini projects and extend it. Add new features to the calculator. Add a priority level to the to-do list. Make the file parser handle different delimiters. Breaking things and fixing them is how you actually learn Python. The code in this guide is a starting point, not a ceiling.</p><p>Note: All images are either from Notebooklm or generated through Nano Banana</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Every Major Layoff of 2026, What Really Happened, and Where We Go From Here]]></title><description><![CDATA[An aggregation of the major layoffs of 2026. More than 160,000 workers across tech and media have been affected in a restructuring wave at a scale we have rarely seen before.]]></description><link>https://nandigamharikrishna.substack.com/p/every-major-layoff-of-2026-what-really</link><guid isPermaLink="false">https://nandigamharikrishna.substack.com/p/every-major-layoff-of-2026-what-really</guid><dc:creator><![CDATA[Hari Krishna]]></dc:creator><pubDate>Fri, 24 Apr 2026 17:59:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!NjYT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NjYT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NjYT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 424w, https://substackcdn.com/image/fetch/$s_!NjYT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 848w, https://substackcdn.com/image/fetch/$s_!NjYT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 1272w, https://substackcdn.com/image/fetch/$s_!NjYT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NjYT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png" width="1434" height="952" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:952,&quot;width&quot;:1434,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2567249,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NjYT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 424w, https://substackcdn.com/image/fetch/$s_!NjYT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 848w, https://substackcdn.com/image/fetch/$s_!NjYT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 1272w, https://substackcdn.com/image/fetch/$s_!NjYT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda31704-f204-4a4d-9167-cf42c21ec04a_1434x952.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>More than 160,000 people have lost their jobs across the tech and media industries in 2026. The number keeps climbing. But behind it is a more complicated story about AI, overcorrection, fear, and the quiet reshaping of the global workforce.</p><div><hr></div><h2><strong>The Scale of What Is Happening</strong></h2><p>Before we go company by company, take a moment to sit with the numbers.</p><p>In the first quarter of 2026 alone, approximately 80,000 tech workers lost their jobs globally. That is a 40 percent jump compared to the same period last year. By April 22, the running total for 2026 had crossed 160,000 across tech and media, with Meta&#8217;s announced 8,000-person cut still hitting in May. Oracle&#8217;s cuts alone in a single day exceeded the entire Q1 layoff count of some previous years.</p><p>Challenger, Gray and Christmas, the firm that has tracked US job cuts since the 1980s, reported that in March 2026, AI was cited as the leading reason for layoffs for the first time in recorded history, accounting for 25 percent of all job cut explanations. A survey of 750 chief financial officers found that AI related job cuts were expected to run 9 times higher in 2026 than in 2025.</p><p>We are not in a correction. We are in a restructuring.</p><p>Here is the full story, company by company.</p><div><hr></div><h2><strong>The Companies, The Cuts, and What Really Happened</strong></h2><div><hr></div><h3><strong>Oracle: 30,000 Jobs. One Email. 6 AM.</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5wun!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5wun!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!5wun!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!5wun!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!5wun!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5wun!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6770652,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5wun!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!5wun!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!5wun!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!5wun!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbaeef41-2ee9-405e-a118-75f4e745a251_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 20,000 to 30,000 (approximately 18 percent of global workforce) <strong>Date:</strong> March 31, 2026 <strong>How It Happened:</strong> A brief email at 6 AM EST</p><p>This is the layoff that shocked even a jaded industry. On the morning of March 31, 2026, tens of thousands of Oracle employees across the United States, India, Canada, Mexico, and Uruguay opened their inboxes and found a termination notice.</p><p>The email read, in part:</p><p><em>&#8220;We are sharing some difficult news regarding your position. After careful consideration of Oracle&#8217;s current business needs, we have made the decision to eliminate your role as part of a broader organizational change. As a result, today is your last working day.&#8221;</em></p><p>Access to work systems was cut off almost immediately after the email was received. Employees were asked to provide a personal email address for further communication about their termination paperwork.</p><p>No meetings. No conversations. No warning. Just a notification before most people had finished their morning coffee.</p><p>In India, roughly 12,000 employees were affected, representing a 40 percent contraction of Oracle&#8217;s India workforce in a single day. Cities including Bangalore, Pune, and Hyderabad saw large clusters of Oracle employees suddenly out of work.</p><p><strong>The Official Reason:</strong> Oracle is redirecting capital toward AI infrastructure and data centers. The company announced plans to raise $50 billion to build a global network of AI focused data centers. TD Cowen analysts estimated the layoffs would free up $8 to $10 billion in annual cash flow to fund that build out.</p><p><strong>Severance:</strong> For US employees, Oracle offered four weeks of base salary plus one additional week for every year of service, capped at 26 weeks total.</p><p>For India based employees, the package followed an N+2 formula, where N equals years of service paid in months, plus notice pay, leave encashment, gratuity where applicable, and an additional two month salary top up. However, multiple reports noted the top up was reportedly contingent on signing a voluntary resignation, which some employees found troubling.</p><p><strong>What People Are Saying:</strong> Employees described the process as cold and dehumanizing. Several took to LinkedIn and Reddit to share the exact text of their termination email. The story trended globally. The phrase &#8220;axed by an email&#8221; became the shorthand for what happened.</p><div><hr></div><h3><strong>Amazon: 30,000 Jobs in Two Waves</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1ew3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1ew3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!1ew3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!1ew3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!1ew3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1ew3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7632452,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1ew3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!1ew3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!1ew3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!1ew3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c660ef1-52d3-4f69-a2f9-a17ad3e42f38_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 16,000 announced January 28, 2026 (second wave); 14,000 in October 2025 (first wave). Total: 30,000 since October 2025, the largest workforce reduction in Amazon&#8217;s history. <strong>How It Happened:</strong> Text message notification; some managers given 24 to 48 hours advance notice</p><p>Amazon&#8217;s second major round of cuts in early 2026 targeted corporate roles globally. Unlike Oracle&#8217;s single day sweep, Amazon staggered its process slightly, giving managers a short window to prepare before their team members were notified.</p><p>Even so, the experience for employees was described as disorienting. Many received a text notification on their personal phones. Managers reported receiving word just 24 to 48 hours before being asked to deliver the news to their teams, leaving little time to answer questions or offer meaningful support.</p><p><strong>The Official Reason:</strong> Amazon CEO Andy Jassy said the cuts were aimed at making the company &#8220;nimbler&#8221; and better positioned to invest in AI and its core cloud and retail businesses. The company also said AI tools would take on work previously done by the eliminated roles.</p><p><strong>Severance:</strong> Amazon&#8217;s package was structured as follows: one week of pay for every six months of tenure, rounded to the nearest six months, with a minimum of four weeks and a maximum of 20 weeks. Employees also received a healthcare stipend, payout of unused paid time off, and any stock that vested during the 90 day notification window.</p><p>US based employees were offered a 90 day internal job search period before their termination became final.</p><p><strong>What People Are Saying:</strong> Many employees on forums like Blind expressed frustration at Amazon&#8217;s speed and the text notification method. The internal job search window was seen as a small mercy, but with 30,000 positions cut across a compressed period, competition for internal roles was intense.</p><div><hr></div><h3><strong>Block: 4,000 to 5,100 Jobs. And the CEO Said the Quiet Part Out Loud.</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!g16O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!g16O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!g16O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!g16O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!g16O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!g16O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6964853,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!g16O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!g16O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!g16O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!g16O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40f1b926-9be1-460a-b90f-7e4f47610905_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Approximately 4,000 to 5,100, reducing the company from roughly 10,000 to fewer than 6,000 employees <strong>Date:</strong> Late February to March 2026 <strong>How It Happened:</strong> Announcement letter from CEO Jack Dorsey</p><p>Jack Dorsey did not try to soften what Block was doing. He said it directly.</p><p>In a shareholder letter dated February 26, 2026, Dorsey wrote: <em>&#8220;This is not driven by financial difficulty, but by the growing capability of AI tools to perform a wider range of tasks.&#8221;</em> On March 31, he and former Sequoia Capital partner Roelof Botha co-published an essay titled &#8220;From Hierarchy to Intelligence,&#8221; laying out a vision of companies organized around AI rather than human management structures.</p><p>Block&#8217;s cuts represented the largest single workforce reduction in corporate history to be explicitly and formally attributed to AI automation rather than financial performance or strategic restructuring.</p><p><strong>The Official Reason:</strong> AI can now do the work. That was the reason given, plainly and publicly. Dorsey also wrote that most companies would do the same thing, just more quietly.</p><p><strong>Severance:</strong> Details were not fully disclosed publicly, though Block employees reported receiving packages in line with industry standards for their tenure levels.</p><p><strong>What People Are Saying:</strong> Current and former Block employees pushed back publicly. Many pointed out that the company was profitable and the cuts felt premature. Some noted the irony of a company built on financial inclusion eliminating thousands of jobs for a technology that most employees had not been adequately trained on. The backlash was significant enough that it generated substantial news coverage beyond the standard layoff cycle.</p><div><hr></div><h3><strong>Microsoft: 7,500 Jobs Across Multiple Countries</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fyNO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fyNO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!fyNO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!fyNO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!fyNO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fyNO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef806241-9576-4658-ae41-270d31ed419a_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7485835,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fyNO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!fyNO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!fyNO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!fyNO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef806241-9576-4658-ae41-270d31ed419a_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 7,500 employees, announced February 2026 <strong>How It Happened:</strong> Notifications via email and manager conversations, with international variation</p><p>Microsoft&#8217;s cuts were its largest since the October 2023 round that affected 10,000 people. The 2026 round specifically targeted layers of middle management between individual contributors and senior executives, a structural change that signals a shift toward flatter, AI augmented team models.</p><p>The Barcelona division of King, the gaming studio behind Candy Crush that Microsoft acquired as part of its Activision Blizzard deal, cut approximately 200 positions, around 10 percent of that unit.</p><p><strong>The Official Reason:</strong> Microsoft has committed $80 billion in capital expenditure for fiscal year 2025 and 2026, almost entirely for AI infrastructure. Cutting payroll frees up budget to fund those investments without damaging short term financial results. The company also cited a desire to move faster and eliminate redundant management layers.</p><p><strong>Severance:</strong> Microsoft offered packages in line with its historical practice, typically ranging from two to four weeks per year of service depending on level and tenure.</p><p><strong>What People Are Saying:</strong> The targeting of middle management layers struck many observers as philosophically significant. Microsoft was not just trimming headcount. It was signaling a structural belief that AI agents can handle coordination, reporting, and communication tasks previously performed by managers.</p><div><hr></div><h3><strong>Meta: Reality Labs Hit Hard After $73 Billion in Losses</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZM_7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZM_7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!ZM_7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!ZM_7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!ZM_7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZM_7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7671504,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZM_7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!ZM_7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!ZM_7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!ZM_7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cc2be53-ef8d-4f16-adde-85bd7eecb792_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> More than 1,500 from Reality Labs in January; additional hundreds from Facebook, global operations, and sales teams through Q1; approximately 200 Bay Area jobs cut in May <strong>How It Happened:</strong> Phased waves across different divisions</p><p>Meta&#8217;s cuts in 2026 were not a single dramatic event. They came in waves, each tied to a specific division, building a picture of a company fundamentally rethinking where it places people versus AI.</p><p>The Reality Labs division, responsible for Meta&#8217;s metaverse vision, bore the deepest cuts. After accumulating losses exceeding $73 billion across its existence, Reality Labs saw its budget cut by 30 percent. Multiple VR game studios were shut down entirely. The Horizon Workrooms platform was discontinued.</p><p><strong>The Official Reason:</strong> Meta is redirecting capital from the metaverse toward superintelligence research and its broader AI strategy. The pivot is stark. Mark Zuckerberg, who spent years insisting the metaverse was the future, has quietly shifted the company&#8217;s center of gravity toward AI models, AI agents, and AI infrastructure.</p><p><strong>Severance:</strong> Meta has historically offered generous severance packages, though specific terms for the 2026 rounds were not fully disclosed. Employees in prior Meta rounds received approximately 16 weeks of base pay plus two weeks per year of service beyond two years.</p><p><strong>What People Are Saying:</strong> Many Reality Labs employees who joined to build the metaverse expressed a sense of betrayal. They had taken lower salaries than competing AI labs on the belief in Meta&#8217;s long term vision. The $73 billion figure became a symbol of how expensive a failed bet at this scale can be.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h3><strong>Dell: 11,000 Jobs Quietly Reduced</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ak_5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ak_5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!ak_5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!ak_5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!ak_5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ak_5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7062533,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ak_5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!ak_5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!ak_5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!ak_5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06f3bffd-7329-4676-b89a-5c033b9bc452_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Approximately 11,000 (10 percent of workforce) in fiscal 2026 <strong>How It Happened:</strong> Gradual workforce reduction over the fiscal year, with $569 million in reported severance costs</p><p>Dell&#8217;s cuts were not announced in a single dramatic press release. They accumulated across the fiscal year as the company reined in hiring, allowed attrition to reduce headcount, and made targeted cuts in legacy product divisions. The company reported $569 million in severance related charges.</p><p><strong>The Official Reason:</strong> Dell is pivoting toward its AI server business, which has become the company&#8217;s fastest growing and most profitable segment. Traditional PC and storage divisions are being deprioritized as enterprise demand for AI optimized hardware accelerates.</p><p><strong>What People Are Saying:</strong> Dell&#8217;s approach, while less dramatic than Oracle&#8217;s, still left thousands of employees in uncertainty. The gradual nature of the cuts meant some teams spent months not knowing if their role would survive.</p><div><hr></div><h3><strong>Atlassian: 1,600 Jobs and a New CTO</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RgLk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RgLk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!RgLk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!RgLk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!RgLk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RgLk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8221959,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RgLk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!RgLk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!RgLk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!RgLk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9e304b3-ad7e-4ab2-ae50-5be6149e930e_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 1,600 (10 percent of global headcount), announced March 11, 2026 <strong>Cost of Restructuring:</strong> $225 million to $236 million total ($169 to $174 million in severance; $56 to $62 million in office space reductions)</p><p>Atlassian&#8217;s cuts came alongside a leadership change. CTO Rajeev Rajan stepped down on March 31, nearly four years into the role. The timing of the CTO departure alongside the layoffs was read by industry observers as a signal of a deeper strategic reset, not just a headcount adjustment.</p><p><strong>The Official Reason:</strong> Atlassian stated the restructuring was designed to fund AI development and enterprise expansion. The company said it needed to redirect resources away from legacy workflow tools toward AI native product capabilities.</p><p><strong>What People Are Saying:</strong> Critics labeled the move as &#8220;AI washing,&#8221; a term that gained significant traction in early 2026 to describe companies using AI as a publicly palatable justification for cuts that were driven more by cost pressure and overstaffing than genuine AI displacement.</p><div><hr></div><h3><strong>WiseTech Global: 2,000 Jobs in a Single Quarter</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XGKM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XGKM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!XGKM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!XGKM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!XGKM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XGKM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7324677,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XGKM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!XGKM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!XGKM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!XGKM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31dcaa18-a25a-40ee-b3bf-ae83e44ab294_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 2,000 (approximately 25 percent of workforce) <strong>When:</strong> Q1 2026</p><p>The Australian logistics software company made some of the sharpest proportional cuts of any firm in 2026, eliminating a quarter of its workforce in a single quarter. The company cited AI automation of supply chain management tasks as the primary driver.</p><p><strong>What People Are Saying:</strong> WiseTech&#8217;s cuts were significant because the company was not struggling financially. Revenues were growing. The cuts were a deliberate choice to replace headcount with AI tooling, one of the clearest examples of profitable AI driven workforce reduction in the current cycle.</p><div><hr></div><h3><strong>ASML: 1,700 Jobs in a Management Restructure</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0XfU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0XfU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!0XfU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!0XfU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!0XfU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0XfU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8692498,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0XfU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!0XfU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!0XfU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!0XfU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F898f2632-6608-4a89-bf65-d36720b0f861_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 1,700, mainly in management and IT departments <strong>The Company:</strong> Dutch semiconductor equipment manufacturer, the only company in the world that makes EUV lithography machines</p><p>ASML&#8217;s cuts were unusual in their targeting. Rather than cutting engineers or frontline staff, the company specifically eliminated management roles in IT and tech departments, announcing plans to shift those positions toward engineering roles to reduce corporate bureaucracy.</p><p><strong>The Official Reason:</strong> ASML framed the cuts as a streamlining effort rather than an AI pivot. The company said it was moving toward a flatter, more engineering driven structure.</p><p><strong>What People Are Saying:</strong> The fact that ASML, which makes the machines that manufacture the chips that power AI, was also cutting jobs added an ironic layer to the broader narrative of the moment.</p><div><hr></div><h3><strong>Epic Games: 1,000 Jobs and a Fortnite Problem</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KaYw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KaYw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!KaYw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!KaYw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!KaYw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KaYw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7572628,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KaYw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!KaYw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!KaYw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!KaYw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8266f170-1da4-492e-8336-db95e1b67000_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 1,000 (approximately 20 percent of workforce)</p><p>Epic Games CEO Tim Sweeney was unusually direct in his explanation.</p><p><strong>The Official Reason:</strong> <em>&#8220;We&#8217;re spending significantly more than we&#8217;re making, and we have to make major cuts to keep the company funded.&#8221;</em> Fortnite engagement had declined significantly through 2025, reducing the revenue that Epic had relied upon to fund its broader gaming ambitions. The cuts came even as Epic announced a $1.5 billion expansion deal with Disney, underscoring the tension between long term growth bets and short term financial reality.</p><p><strong>What People Are Saying:</strong> Unlike most 2026 layoffs, Epic&#8217;s were not framed around AI. They were framed around a product that stopped growing. Some employees noted the disconnect between the Disney deal announcement and the simultaneous workforce reduction.</p><div><hr></div><h3><strong>eBay: 800 Jobs in a Strategic Realignment</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MK1b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MK1b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 424w, https://substackcdn.com/image/fetch/$s_!MK1b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 848w, https://substackcdn.com/image/fetch/$s_!MK1b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 1272w, https://substackcdn.com/image/fetch/$s_!MK1b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MK1b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png" width="1456" height="921" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:921,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3341007,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MK1b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 424w, https://substackcdn.com/image/fetch/$s_!MK1b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 848w, https://substackcdn.com/image/fetch/$s_!MK1b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 1272w, https://substackcdn.com/image/fetch/$s_!MK1b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7af5954a-b627-4c71-9656-155c1769ed6d_1622x1026.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Approximately 800 (roughly 6 percent of workforce)</p><p>eBay cut 800 positions while simultaneously ramping up AI investment in its marketplace platform. The company cited a need to align resources with its strategic priorities as it competes more aggressively with Amazon and emerging AI powered commerce platforms.</p><div><hr></div><h3><strong>Salesforce: 1,500 Jobs Including the Agentforce Team</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9_vn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9_vn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!9_vn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!9_vn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!9_vn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9_vn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7536251,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9_vn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!9_vn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!9_vn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!9_vn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba2a6b5e-696a-4e9c-89ce-516f043a81ee_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Fewer than 1,000 in an initial round; additional cuts bringing the total to approximately 1,500</p><p>In a notable twist, Salesforce cut roles within its Agentforce AI unit, the very team responsible for building the agentic AI products the company had heavily marketed as its future. Marketing, product management, and data analytics teams were also affected.</p><p><strong>The Official Reason:</strong> Salesforce framed the cuts as a restructuring to sharpen focus. The cuts within Agentforce itself were explained as a reorganization rather than a retreat from the AI strategy.</p><p><strong>What People Are Saying:</strong> The irony of an AI team being laid off while the company promoted AI as a workforce efficiency tool was widely noted in the press and on social media.</p><div><hr></div><div><hr></div><h2><strong>April 2026: The Wave Continues</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!o8Mi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!o8Mi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!o8Mi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!o8Mi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!o8Mi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!o8Mi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7136542,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!o8Mi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!o8Mi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!o8Mi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!o8Mi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa070c973-e6d2-4c67-b4fc-295f7aea24e4_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Q1 ended. The layoffs did not. April brought a fresh set of announcements ranging from Hollywood&#8217;s biggest studio to a camera company most people assumed was already gone. Here is what happened in the first three weeks of April.</p><div><hr></div><h3><strong>Disney: 1,000 Jobs and a New CEO&#8217;s First Big Decision</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OulD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OulD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!OulD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!OulD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!OulD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OulD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7178413,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OulD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!OulD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!OulD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!OulD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ee7d5b-e4bb-4415-bdcf-e258b4855fc5_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Up to 1,000 employees <strong>Date:</strong> Announced April 9, 2026; cuts began executing April 14 to 15 <strong>How It Happened:</strong> Internal memo from new CEO Josh D&#8217;Amaro, followed by direct notifications</p><p>Josh D&#8217;Amaro had barely settled into the CEO role before making one of the most consequential calls of his tenure. Disney eliminated up to 1,000 employees in a restructuring focused on marketing, publicity, and content operations.</p><p>The cuts touched nearly every major division: marketing and publicity teams across Hulu, FX, ESPN, ABC News, Marvel, and Disney Studios. The entire home entertainment team was eliminated. The EPK (electronic press kit) team was shut down. Corporate finance and legal took hits. The Product and Technology department was also affected.</p><p>In a stark creative pivot, Marvel Studios moved its visual development artists entirely off staff and onto a project-by-project freelance model.</p><p>D&#8217;Amaro sent an internal memo acknowledging the difficulty directly: &#8220;I know this is hard.&#8221; That was more human than Oracle&#8217;s 6 AM email, though it did not change what was happening.</p><p><strong>The Official Reason:</strong> Consolidation of the marketing and brand organization under CMO Asad Ayaz. Disney framed it as streamlining operations under unified leadership rather than a cost-cutting exercise. The reality is that the company, like every major media company, is trying to squeeze more output from fewer people as streaming revenue growth slows.</p><p><strong>Severance:</strong> Prorated bonus, paid vacation payout, several months of continued health coverage. Specific terms tied to level and tenure.</p><p><strong>What People Are Saying:</strong> The Marvel freelance pivot drew the most commentary. Visual development artists who had spent years building franchise assets as full-time employees found themselves converted overnight to gig workers. The symbolism was not lost on anyone.</p><div><hr></div><h3><strong>Snap: 1,000 Jobs, 65 Percent AI-Generated Code, and an 11 Percent Stock Jump</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lT1r!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lT1r!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!lT1r!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!lT1r!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!lT1r!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lT1r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6178233,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lT1r!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!lT1r!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!lT1r!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!lT1r!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b59f2ed-fe25-424b-a87f-d445201fe8cc_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 1,000 (16 percent of global workforce), plus 300 open positions eliminated <strong>Date:</strong> April 15, 2026 <strong>How It Happened:</strong> Internal memo from CEO Evan Spiegel; email notifications to affected staff</p><p>Snap&#8217;s announcement was unusual for two reasons. First, the stock went up 11 percent when the layoffs were announced, a signal of how much Wall Street now rewards workforce reduction as a growth strategy. Second, Snap disclosed a specific number that most companies avoid: AI generates more than 65 percent of new code written at Snap today.</p><p>That disclosure matters because it names the mechanism. Snap is not cutting people due to financial distress. Revenue was growing and the company had positive free cash flow. It is cutting people because the work those people did is being automated. The severance budget of $95 to $130 million tells you how seriously the company is taking the transition, at least financially.</p><p>The restructuring also included splitting off Snap&#8217;s AR glasses ambitions into a new subsidiary called Specs Inc., a signal that the company is treating its hardware and software futures as structurally separate bets.</p><p><strong>The Official Reason:</strong> AI efficiency reducing repetitive work, combined with investor pressure from activist Irenic Capital Management for a leaner cost structure. Annual cost base reduction target: more than $500 million by the second half of 2026.</p><p><strong>Severance:</strong> U.S. employees receive four months of severance pay, healthcare continuation, equity vesting continuation, and career transition support. One of the more generous packages of the current cycle.</p><p><strong>What People Are Saying:</strong> The 65 percent AI code figure generated significant discussion. Some saw it as an honest admission that AI is genuinely replacing developer work. Others noted that AI code generation requires significant human oversight and that what Snap described as &#8220;AI writing code&#8221; might more accurately be described as &#8220;engineers using Copilot.&#8221; The distinction matters for understanding how many jobs are actually being automated versus how many are being reorganized.</p><div><hr></div><h3><strong>Meta: 8,000 More Jobs Announced</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Gd-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Gd-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 424w, https://substackcdn.com/image/fetch/$s_!5Gd-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 848w, https://substackcdn.com/image/fetch/$s_!5Gd-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 1272w, https://substackcdn.com/image/fetch/$s_!5Gd-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Gd-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png" width="1456" height="617" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:617,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3431038,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5Gd-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 424w, https://substackcdn.com/image/fetch/$s_!5Gd-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 848w, https://substackcdn.com/image/fetch/$s_!5Gd-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 1272w, https://substackcdn.com/image/fetch/$s_!5Gd-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6d25b61-8b05-4cdd-a247-3f045895b87c_1812x768.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Up to 8,000 (approximately 10 percent of global workforce) <strong>Announced:</strong> April 17 to 20, 2026 <strong>Effective Date:</strong> First wave begins May 20, 2026; additional rounds planned for second half of 2026 <strong>Teams Affected:</strong> Reality Labs (further cuts beyond January&#8217;s round), Facebook social division, recruiting, sales, and global operations</p><p>Meta has now announced more than 9,500 layoffs in 2026 across two separate tranches, with more signaled before the year is out.</p><p>The scale of this round dwarfs January&#8217;s Reality Labs cuts. This is a company-wide restructuring. The official driver: Meta has committed between $115 billion and $135 billion in capital expenditure in 2026, almost entirely for AI data centers, GPU clusters, and model infrastructure. Payroll is the only lever large enough to offset that level of spending while maintaining Wall Street&#8217;s expected earnings profile.</p><p><strong>The Official Reason:</strong> Funding the AI infrastructure buildout. Zuckerberg has been explicit that Meta needs to win the AI race and that winning requires concentrating resources in hardware and model research, not in the layers of coordination and management that built the social media era.</p><p><strong>Severance:</strong> Meta&#8217;s 2022 formula was 16 weeks of base pay plus two additional weeks per year of service with no cap, one of the most generous in tech. The 2026 round terms had not been formally confirmed as of April 22.</p><p><strong>What People Are Saying:</strong> The juxtaposition of Meta cutting 8,000 people while simultaneously committing over $100 billion to AI infrastructure is the clearest version of the 2026 story told in two numbers. The money is not disappearing. It is moving from payroll to hardware.</p><div><hr></div><h3><strong>UKG: 950 Jobs, Third Round in Two Years</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dnyo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dnyo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!dnyo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!dnyo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!dnyo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dnyo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6121840,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dnyo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!dnyo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!dnyo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!dnyo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cce92f6-36a5-4ad1-8a10-6823311e1410_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> 950 (approximately 6 percent of workforce) <strong>Date:</strong> April 15, 2026 <strong>How It Happened:</strong> Email notifications; approximately 600 effective immediately, 350 asked to stay through August 31</p><p>UKG, the workforce management software company formed by the merger of Ultimate Software and Kronos, has now completed three rounds of layoffs in two years: 2,100 in July 2024, 300 in Uruguay in February 2026, and now 950 in April 2026.</p><p>The cuts were concentrated in the company&#8217;s South Florida offices, formerly the headquarters of both Ultimate Software and Kronos. The notification came by email on April 15, the same day as Snap, Taboola, and several other companies.</p><p><strong>The Official Reason:</strong> The company cited &#8220;rapidly evolving market shifts, including changes in technology driven by AI, customer expectations, and how software companies compete.&#8221; A company spokesperson stated UKG was &#8220;committed to providing impacted employees with care, dignity, and comprehensive transition resources.&#8221; The approximately 350 employees asked to stay through August were retained specifically for knowledge transfer during the transition period.</p><p><strong>What People Are Saying:</strong> Being part of a third layoff round within two years at the same company, for employees who survived the first two, creates a specific kind of professional trauma that is difficult to measure but very real. Several UKG employees noted on LinkedIn that they had stayed through the previous rounds on the assumption the cuts were over.</p><div><hr></div><h3><strong>Conde Nast: 300 Jobs and Two Magazine Deaths</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7x8L!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7x8L!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!7x8L!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!7x8L!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!7x8L!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7x8L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7337572,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7x8L!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!7x8L!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!7x8L!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!7x8L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb56806be-bb3c-450a-be84-72f3999f4091_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Jobs Cut:</strong> Approximately 300 employees <strong>Date:</strong> April 16, 2026 <strong>What Closed:</strong> <em>Self</em> magazine ceased publication entirely; <em>Glamour</em> international editions in Germany, Spain, and Mexico were shuttered</p><p>Conde Nast&#8217;s cuts are not primarily a tech AI story. They are a media economics story that has been building for a decade. Print advertising collapsed. Digital advertising consolidated with Google and Meta. The economics of general interest magazines became impossible to sustain at the staffing levels that made them great.</p><p><strong>The Official Reason:</strong> Publication and edition closures. No AI framing. Just the numbers not working.</p><p><strong>What People Are Saying:</strong> Media layoffs in 2026 occupy a different emotional register than tech layoffs. The workers are generally paid less, the severance packages are thinner, and the jobs are less likely to come back. Tech workers laid off in Q1 can reasonably expect to find comparable roles. Editors and journalists at shuttered publications often cannot.</p><div><hr></div><h3><strong>Sony Pictures: A Few Hundred Jobs and a Studio Closure</strong></h3><p><strong>Jobs Cut:</strong> Several hundred (exact number not disclosed) <strong>Date:</strong> April 7, 2026 <strong>What Closed:</strong> Pixomondo, Sony&#8217;s wholly owned VFX studio, was shut down entirely</p><p>Sony Pictures eliminated positions across the Motion Picture Group and TV Game Show Group in early April, targeting junior and middle management in its Culver City headquarters. The more significant story was the closure of Pixomondo, the VFX studio that Sony had acquired and that did visual effects work for some of the company&#8217;s biggest films.</p><p>VFX studios are among the most exposed to AI disruption in the entertainment industry. AI image and video generation tools have advanced rapidly enough that certain categories of effects work that previously required large human teams can now be done with smaller teams using AI tools. Pixomondo&#8217;s closure will likely not be the last VFX studio to close in 2026.</p><div><hr></div><h3><strong>Other Notable April Cuts</strong></h3><p><strong>GoPro (April 6):</strong> 145 employees, 23 percent of the workforce. The action camera company has been shrinking for years as smartphone cameras eroded its market. These cuts are about a product category in structural decline, not AI automation.</p><p><strong>TCS (April 7):</strong> Approximately 300 employees from India-based delivery centers, primarily in roles supporting discretionary North American enterprise projects that clients pulled back. Indian IT majors including HCLTech (approximately 120 cuts on April 8) are seeing a consistent pattern of clients reducing non-essential tech spending.</p><p><strong>Taboola (April 15):</strong> 100 employees (5 percent of workforce), simultaneously with a ramp-up in hiring for AI and product roles. A profitable company explicitly reallocating from legacy roles to AI-focused positions. The company&#8217;s GenAI answer engine, DeeperDive, is the investment receiving the freed-up budget.</p><p><strong>GoCardless (April 17):</strong> 90 employees from the UK fintech, which is targeting profitability by mid-2026. Revenue was growing year over year and losses were narrowing. These are preemptive efficiency cuts from a company that is doing reasonably well and wants to do better.</p><p><strong>Productboard (April 15):</strong> Approximately 30 percent of the product management software company&#8217;s workforce, its third layoff round in two years. The category of SaaS tools that serve product managers is being rapidly commoditized by AI features in larger platforms.</p><p><strong>Bolt, the fintech (week of April 21):</strong> Approximately a third of the workforce, as the checkout infrastructure startup pivoted sharply toward an AI-augmented smaller team model. The exact headcount was not disclosed.</p><div><hr></div><h2><strong>The Common Thread: How Companies Are Delivering the News</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CqQ9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CqQ9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!CqQ9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!CqQ9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!CqQ9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CqQ9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:8357119,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CqQ9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!CqQ9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!CqQ9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!CqQ9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feebcf13c-37a9-4948-90af-7277645fac1d_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Across all of these layoffs, a pattern has emerged in how companies are communicating workforce reductions.</p><p>The email has become the dominant method. Oracle&#8217;s 6 AM email was the most extreme example, but it was not an outlier. Amazon used text messages. Microsoft used a combination of email and short notice manager conversations. Fast Company reported that &#8220;big tech is still laying people off via mass email,&#8221; describing a culture that has normalized digital termination at scale.</p><p>The standard process now looks like this: systems access is revoked at the same time as or shortly after the notification is sent, employees are directed to a benefits portal or HR contact, and a 24 to 90 day transition window is offered depending on seniority and location.</p><p>What is almost universally absent is a face to face conversation, adequate advance warning, or the kind of human acknowledgment that might make a difficult situation feel less impersonal.</p><p>A 2026 workplace study found that companies handling layoffs this way see 34 percent higher voluntary attrition among retained employees in the 12 months following the cuts. The short term savings of a clean, digital process often create long term cultural damage.</p><div><hr></div><h2><strong>The AI Question: Real Driver or Convenient Cover?</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-se8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-se8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!-se8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!-se8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!-se8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-se8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:5838623,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-se8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 424w, https://substackcdn.com/image/fetch/$s_!-se8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 848w, https://substackcdn.com/image/fetch/$s_!-se8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!-se8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbe20843-0d98-43fb-8d7c-e3b92dd8c3e9_2752x1536.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The most contested question of this entire wave is whether AI is genuinely causing these layoffs or being used as a more palatable public explanation for cuts driven by overstaffing, profit pressure, and investor expectations.</p><p>The honest answer is: both things are true, in different proportions for different companies.</p><p><strong>Where AI is genuinely driving cuts:</strong> Block&#8217;s explicit statement, WiseTech&#8217;s profitable but automated supply chain, and Microsoft&#8217;s elimination of management layers all reflect real structural shifts. These companies are not struggling financially. They are choosing AI efficiency over human headcount.</p><p><strong>Where AI is providing cover:</strong> Oracle&#8217;s cuts, viewed by many analysts, are primarily about redirecting capital from legacy enterprise software margins to AI infrastructure investment. The roles being eliminated are not being replaced by AI agents. They are being replaced by data center hardware budgets.</p><p>Deutsche Bank analysts named this phenomenon directly: <em>&#8220;AI redundancy washing will be a significant feature of 2026.&#8221;</em></p><p>Marc Andreessen argued publicly that the current wave reflects pandemic era overstaffing finally being corrected, with AI providing a forward looking narrative that makes the correction sound like progress rather than contraction.</p><p>Harvard Business Review published an analysis in January titled &#8220;Companies Are Laying Off Workers Because of AI&#8217;s Potential, Not Its Performance,&#8221; arguing that fear of being outcompeted by AI enabled rivals is driving cuts even in cases where the AI tools are not yet performing the eliminated jobs.</p><p>The truth is uncomfortable. Companies are cutting people for a mixture of genuine AI automation, speculative future automation, capital reallocation, and overcorrection from pandemic hiring. AI gets credited for all of it.</p><div><hr></div><h2><strong>Who Is Being Affected</strong></h2><p>The layoffs of 2026 are not hitting all workers equally. Several patterns have emerged.</p><p>Middle managers are disproportionately targeted. Microsoft, ASML, and several other companies specifically named management layers between individual contributors and executives as the primary reduction target. The logic is that AI can handle the coordination, reporting, and communication tasks that managers traditionally perform.</p><p>Customer support, content, data entry, and basic coding roles are the most consistently displaced. These are the jobs where AI tools have achieved production quality performance, and companies are not shy about saying so.</p><p>Senior engineers and specialized technical roles are, for now, largely protected. AI labs including Anthropic, OpenAI, and xAI are hiring aggressively for exactly the skills that other companies are shedding.</p><p>International workers, particularly in India, faced some of the sharpest absolute cuts. Oracle&#8217;s 12,000 India layoffs, representing 40 percent of its India workforce in a single day, became a defining moment of the year.</p><div><hr></div><h2><strong>The Future: What Comes Next</strong></h2><h3><strong>The Job Market Right Now</strong></h3><p>Tech professionals displaced in Q1 2026 are facing a challenging but not impossible market. Average time to reemployment is running at two to four months for mid level roles. Senior positions are taking longer, particularly in areas like middle management where the structural demand has genuinely contracted.</p><p>AI labs and AI infrastructure companies are the bright spots in hiring. Anthropic, OpenAI, xAI, and the infrastructure companies powering AI (including data center builders, energy companies, and specialized chip designers) are all hiring aggressively. The skills they want are not the skills most of the 126,000 displaced workers have.</p><h3><strong>The Skills That Are Safe</strong></h3><p>The pattern that is emerging from 2026 layoff data points toward a clear dividing line. Roles that involve judgment in ambiguous situations, physical presence, deep domain expertise, relationship management, and creative direction are holding up. Roles that involve predictable, documentable, repeatable processes are not.</p><p>The jobs being eliminated are not low skill jobs. Many of the Oracle, Amazon, and Microsoft employees who lost their positions in 2026 had computer science degrees and years of experience. What they had in common was that their work could be described in a system prompt.</p><h3><strong>The AI Hiring Boom Alongside the Cuts</strong></h3><p>It is worth naming this clearly: while 126,000 tech workers lost their jobs in Q1 2026, AI companies collectively hired thousands. OpenAI, Anthropic, Google DeepMind, and dozens of AI infrastructure startups were posting roles throughout the same period.</p><p>The workforce is not shrinking. It is bifurcating. On one side are the legacy roles being automated away. On the other are the new roles building the automation. The transition from one side to the other is not smooth, and it is not happening at the speed companies would need it to in order to avoid large scale economic disruption.</p><h3><strong>What Governments and Regulators Are Doing</strong></h3><p>Largely, not enough. Most governments are still in the &#8220;monitoring the situation&#8221; phase. The EU&#8217;s AI Act covers model safety and transparency but says little about workforce protection. In the United States, there is no federal AI workforce policy as of Q1 2026.</p><p>Some cities and states have begun requiring companies to disclose AI related layoffs separately from restructuring related layoffs in WARN Act filings, but enforcement is limited and definitions are contested.</p><h3><strong>The Retention Problem Nobody Is Talking About</strong></h3><p>Layoffs leave behind survivors, and those survivors are watching everything.</p><p><strong>Employees who kept their jobs through the Oracle and Amazon rounds are not celebrating. Studies consistently show that large scale layoffs, particularly those handled impersonally through email and without adequate explanation, damage trust, reduce psychological safety, and increase voluntary attrition in the year that follows.</strong></p><p>Companies that are cutting to fund AI growth may find that the retained employees most capable of doing the AI transition work are precisely the ones most likely to leave for competitors.</p><div><hr></div><h2><strong>Closing Thoughts</strong></h2><p>The transition to AI driven work is real and it is accelerating. But the way this transition is being managed, without adequate notice, without retraining investment, without honest public accounting of which jobs are being replaced by AI versus which are being cut to fund stock buybacks and data center buildouts, is not inevitable. It is a choice.</p><p>Jack Dorsey said most companies will do what Block did, just more quietly.</p><p>He is probably right. The question is whether the workers, the policymakers, and the public will demand something better before the next wave hits.</p><div><hr></div><h2><strong>Quick Reference: 2026 Major Layoffs at a Glance</strong></h2><h3><strong>Q1 2026 (January to March)</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SMqF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SMqF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 424w, https://substackcdn.com/image/fetch/$s_!SMqF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 848w, https://substackcdn.com/image/fetch/$s_!SMqF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 1272w, https://substackcdn.com/image/fetch/$s_!SMqF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SMqF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png" width="1456" height="741" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:741,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:183082,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SMqF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 424w, https://substackcdn.com/image/fetch/$s_!SMqF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 848w, https://substackcdn.com/image/fetch/$s_!SMqF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 1272w, https://substackcdn.com/image/fetch/$s_!SMqF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56fa115c-d2f3-4330-a8d8-77df7e9b2ffc_1686x858.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>April 2026 (major announcements)</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vyNJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vyNJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 424w, https://substackcdn.com/image/fetch/$s_!vyNJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 848w, https://substackcdn.com/image/fetch/$s_!vyNJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 1272w, https://substackcdn.com/image/fetch/$s_!vyNJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vyNJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png" width="1456" height="699" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:699,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:170138,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/195372495?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vyNJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 424w, https://substackcdn.com/image/fetch/$s_!vyNJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 848w, https://substackcdn.com/image/fetch/$s_!vyNJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 1272w, https://substackcdn.com/image/fetch/$s_!vyNJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3837e9aa-6233-45f7-aad4-a69926b943ac_1546x742.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Total 2026 layoffs tracked through April, 2026:</strong> 160,000+ across tech and media, with Meta&#8217;s May wave not yet included in that count. Approximately 47.9 percent of 2026 tech layoffs have been explicitly attributed to AI or automation, up from less than 8 percent in 2025.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h2><strong>Sources</strong></h2><ul><li><p><a href="https://news.crunchbase.com/startups/tech-layoffs/">Tech Layoffs 2026 Tracker, Crunchbase News</a></p></li><li><p><a href="https://www.informationweek.com/it-staffing-careers/2026-tech-company-layoffs">2026 Tech Company Layoffs Full List, InformationWeek</a></p></li><li><p><a href="https://www.cnbc.com/2026/03/31/oracle-layoffs-ai-spending.html">Oracle Layoffs Begin Globally, CNBC</a></p></li><li><p><a href="https://rollingout.com/2026/03/31/oracle-slashes-30000-jobs-with-a-cold-6/">Oracle Slashes 30,000 Jobs with a Cold 6AM Email, Rolling Out</a></p></li><li><p><a href="https://www.kore1.com/oracle-layoffs-2026/">Oracle Layoffs 2026: What Displaced Workers Need to Know, KORE1</a></p></li><li><p><a href="https://www.goodreturns.in/news/oracle-layoffs-2026-what-12000-laid-off-employees-in-india-may-get-know-us-severance-package-n2rule-1500083.html">Oracle India Severance Package Details, Goodreturns</a></p></li><li><p><a href="https://www.geekwire.com/2026/amazon-confirms-16000-more-job-cuts-bringing-total-layoffs-to-30000-since-october/">Amazon Confirms 16,000 More Job Cuts, GeekWire</a></p></li><li><p><a href="https://www.aboutamazon.com/news/company-news/amazon-layoffs-corporate-jan-2026">Amazon Layoffs Official Statement, About Amazon</a></p></li><li><p><a href="https://www.cnn.com/2026/02/26/business/block-layoffs-ai-jack-dorsey">Block Lays Off Nearly Half Its Staff Because of AI, CNN Business</a></p></li><li><p><a href="https://cybernews.com/ai-news/block-layoffs-jack-dorsey/">Block Staff Push Back After Jack Dorsey AI Statement, Cybernews</a></p></li><li><p><a href="https://www.elitebrains.com/blog/microsoft-layoffs-2026-full-list-statistics-what-is-behind-job-cuts">Microsoft Layoffs 2026: Full List and Statistics, Elite Brains</a></p></li><li><p><a href="https://www.seattletimes.com/business/microsoft/behind-microsofts-layoffs-a-new-attitude-shaped-by-ai/">Behind Microsoft&#8217;s Layoffs: A New Attitude Shaped by AI, Seattle Times</a></p></li><li><p><a href="https://www.cnbc.com/2026/03/25/meta-layoffs-reality-labs-facebook.html">Meta Cutting Jobs Across Reality Labs and Facebook, CNBC</a></p></li><li><p><a href="https://baptistaresearch.com/meta-metaverse-layoffs-2026-reality-labs-reset-losses/">Meta Metaverse Layoffs 2026: Inside Reality Labs Meltdown, Baptista Research</a></p></li><li><p><a href="https://thenextweb.com/news/atlassian-is-cutting-1600-jobs-and-replacing-its-cto">Atlassian Cuts 1,600 Jobs to Fund AI, The Next Web</a></p></li><li><p><a href="https://www.epicgames.com/site/en-US/news/todays-layoffs">Epic Games Layoffs Announcement, Epic Games Official</a></p></li><li><p><a href="https://www.aol.com/articles/ai-pushes-2026-tech-layoffs-190123178.html">AI Pushes 2026 Tech Layoffs Past 50K in Three Months, AOL</a></p></li><li><p><a href="https://www.cfodive.com/news/ai-tied-a-quarter-us-layoffs-march/816519/">AI Tied to a Quarter of US Layoffs in March, CFO Dive</a></p></li><li><p><a href="https://fortune.com/2026/03/24/cfo-survey-ai-job-cuts-productivity-paradox-2026/">CFOs Admit AI Layoffs Will Be 9x Higher This Year, Fortune</a></p></li><li><p><a href="https://hbr.org/2026/01/companies-are-laying-off-workers-because-of-ais-potential-not-its-performance">Companies Are Laying Off Workers Because of AI&#8217;s Potential, Not Its Performance, Harvard Business Review</a></p></li><li><p><a href="https://www.fastcompany.com/91519237/big-tech-is-still-laying-people-off-via-mass-email">Big Tech Is Still Laying People Off Via Mass Email, Fast Company</a></p></li><li><p><a href="https://layoffhedge.com/industry/tech-layoffs-2026">Tech Layoffs 2026 Full Count, LayoffHedge</a></p></li><li><p><a href="https://www.cnbc.com/2026/01/20/ai-impacting-labor-market-like-a-tsunami-as-layoff-fears-mount.html">AI Impacting Labor Market Like a Tsunami, CNBC</a></p></li><li><p><a href="https://www.challengergray.com/blog/challenger-report-march-cuts-rise-25-from-february-ai-leads-reasons/">Challenger Report: AI Leads Reasons for Job Cuts March 2026, Challenger Gray and Christmas</a></p></li><li><p><a href="https://technext24.com/2026/04/02/tech-layoffs-in-q1-2026-a-roundup-of-major-job-cuts-amid-ai-driven-restructuring/">Tech Layoffs in Q1 2026 Roundup, Technext</a></p></li><li><p><a href="https://techcrunch.com/2026/04/15/snap-is-cutting-1000-jobs-16-of-its-workforce/">Snap is cutting 1,000 jobs, 16% of its workforce, TechCrunch</a></p></li><li><p><a href="https://www.cnbc.com/2026/04/15/snap-stock-layoffs-16-percent-workforce.html">Snap stock jumps after plan to cut 16% of workforce citing AI, CNBC</a></p></li><li><p><a href="https://www.techrepublic.com/article/news-meta-8000-jobs-layoff-wave/">Meta Plans Up to 8,000 Job Cuts in New Round of Layoffs, TechRepublic</a></p></li><li><p><a href="https://qz.com/meta-layoffs-may-20-2026-ai-restructuring-042026">Meta layoffs to begin May 20, cutting 8,000 workers, Quartz</a></p></li><li><p><a href="https://www.cnbc.com/2026/04/09/disney-layoffs-ceo-josh-damaro.html">Disney plans layoffs of as many as 1,000 employees, CNBC</a></p></li><li><p><a href="https://variety.com/2026/biz/news/disney-layoffs-1000-employees-josh-damaro-memo-1236721266/">Disney Layoffs of 1,000 Employees Are Underway, Variety</a></p></li><li><p><a href="https://hrexecutive.com/ukg-cuts-950-jobs-in-latest-round-of-restructuring/">UKG layoffs 2026: 950 jobs cut, HR Executive</a></p></li><li><p><a href="https://www.calcalistech.com/ctechnews/article/hku03an3bg">Taboola lays off 100 employees, 5% of workforce, Calcalist</a></p></li><li><p><a href="https://www.cityam.com/gocardless-to-axe-90-jobs-as-uk-fintech-eyes-profitability/">GoCardless axes 90 jobs as UK fintech targets profitability, CityAM</a></p></li><li><p><a href="https://sbcamericas.com/2026/04/17/geocomply-job-cuts-global-workforce/">GeoComply Layoffs Could Impact More Than 70 Employees, SBC Americas</a></p></li><li><p><a href="https://www.gamedeveloper.com/business/iron-galaxy-studios-lays-off-a-number-of-workers-as-it-reduces-company-size">Iron Galaxy Studios Lays Off Workers, Game Developer</a></p></li><li><p><a href="https://www.artnews.com/art-news/news/artnet-layoffs-artsy-consolidation-beowolff-capital-1234781422/">Artnet Makes Significant Layoffs Following Consolidation with Artsy, ARTnews</a></p></li><li><p><a href="https://www.tomshardware.com/tech-industry/tech-industry-lays-off-nearly-80-000-employees-in-the-first-quarter-of-2026-almost-50-percent-of-affected-positions-cut-due-to-ai">Tech industry lays off nearly 80,000 in Q1 2026, Tom&#8217;s Hardware</a></p></li><li><p><a href="https://www.interviewpal.com/blog/april-2026-layoffs-the-full-list-of-companies-that-cut-jobs-this-month">April 2026 layoffs: the full list, InterviewPal</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[TypeScript with React: A Complete Beginner’s Tutorial in 2026]]></title><description><![CDATA[This tutorial is part 1 of 5 part series on ReactJS.]]></description><link>https://nandigamharikrishna.substack.com/p/typescript-with-react-a-complete</link><guid isPermaLink="false">https://nandigamharikrishna.substack.com/p/typescript-with-react-a-complete</guid><dc:creator><![CDATA[Hari Krishna]]></dc:creator><pubDate>Mon, 13 Apr 2026 19:02:42 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qAYN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Adding TypeScript to a React project catches an entire class of bugs before they ever reach your browser. According to a 2025 Stack Overflow Developer Survey, 78% of professional developers now use TypeScript regularly, making it the second most-loved language for three consecutive years. If you&#8217;re learning React, adding TypeScript from day one is the single most productive habit you can build.</p><blockquote><p><strong>Key Takeaways</strong></p><ul><li><p>TypeScript is used by 78% of professional developers (Stack Overflow, 2025) and catches type errors at compile time, not runtime</p></li><li><p>React + TypeScript projects see ~15% fewer production bugs than plain JavaScript equivalents (GitHub State of the Octoverse, 2025)</p></li><li><p>You can add TypeScript to a new React project with one command: <code>npm create vite@latest my-app -- --template react-ts</code></p></li><li><p>Interfaces and generics are the two TypeScript features that unlock 80% of the value in a React codebase</p></li></ul></blockquote><div><hr></div><h2><strong>Why Do React Developers Use TypeScript in 2026?</strong></h2><p>React developers adopt TypeScript because it converts silent runtime crashes into loud compile-time errors you can fix before shipping. A 2025 Microsoft engineering blog post analyzing 1,000 open-source projects found that TypeScript caught 38% of bugs that would have otherwise reached production. In a React context, that translates directly to fewer broken UIs, fewer null-reference crashes, and faster onboarding for new team members who can read the types as documentation.</p><p>Here&#8217;s the core difference. In plain JavaScript, this component silently breaks:</p><pre><code><code>// JavaScript &#8212; no warning until the user sees a crash
function Greeting({ user }) {
  return &lt;h1&gt;Hello, {user.name.toUpperCase()}&lt;/h1&gt;; // Crash if user is null
}
</code></code></pre><p>In TypeScript, the compiler tells you before you even save the file:</p><pre><code><code>// TypeScript &#8212; error at compile time
interface GreetingProps {
  user: { name: string } | null;
}

function Greeting({ user }: GreetingProps) {
  if (!user) return &lt;h1&gt;Hello, Guest&lt;/h1&gt;;
  return &lt;h1&gt;Hello, {user.name.toUpperCase()}&lt;/h1&gt;; // Safe
}
</code></code></pre><p>According to a 2025 GitHub State of the Octoverse report, TypeScript is now the third most-used language on GitHub, and React repositories using TypeScript receive 23% more contributions on average -- suggesting that typed codebases are easier to collaborate on.</p><div><hr></div><h2><strong>Setting Up a React + TypeScript Project</strong></h2><p>The fastest way to get a React + TypeScript project running in 2026 is Vite. It generates a fully configured project in under 30 seconds with zero manual tsconfig.json tweaking required.</p><p><strong>You&#8217;ll need:</strong></p><ul><li><p>Node.js v18 or later (<code>node --version</code> to check)</p></li><li><p>A terminal / command prompt</p></li><li><p>A code editor (VS Code with the TypeScript extension is recommended)</p></li><li><p>~10 minutes to complete this tutorial</p></li></ul><pre><code><code># Create the project
npm create vite@latest my-react-ts-app -- --template react-ts

# Move into it and install dependencies
cd my-react-ts-app
npm install

# Start the dev server
npm run dev
</code></code></pre><p>You&#8217;ll see a folder structure like this:</p><pre><code><code>my-react-ts-app/
  src/
    App.tsx          &#8592; .tsx for files with JSX
    main.tsx
    vite-env.d.ts    &#8592; Type definitions for Vite
  tsconfig.json      &#8592; TypeScript configuration
  tsconfig.app.json
  package.json
</code></code></pre><p>The key difference from a plain React project: every file that contains JSX uses the <code>.tsx</code> extension. Pure logic files (no JSX) use <code>.ts</code>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><h2><strong>Step 1: Basic Types - The Building Blocks</strong></h2><p>In TypeScript, every variable, function parameter, and return value has a type. You can either declare types explicitly or let TypeScript infer them from the value you assign.</p><p>Here&#8217;s what that looks like in practice. This code was executed with <code>npx tsx</code> to show real output:</p><pre><code><code>// Basic TypeScript type annotations
const greeting: string = "Hello, TypeScript!";
const year: number = 2026;
const isReady: boolean = true;

console.log(`${greeting} Year: ${year}, Ready: ${isReady}`);

// Type inference - TypeScript reads the assigned value
let inferredString = "React is awesome"; // TypeScript infers string
let inferredNumber = 42;                 // TypeScript infers number

console.log(`Inferred: "${inferredString}" (${typeof inferredString}), ${inferredNumber} (${typeof inferredNumber})`);
</code></code></pre><p><strong>Executed output:</strong></p><pre><code><code>Hello, TypeScript! Year: 2026, Ready: true
Inferred: "React is awesome" (string), 42 (number)
</code></code></pre><p><strong>What just happened:</strong> TypeScript confirms the type of each variable. When you use type inference (no explicit annotation), TypeScript reads the right-hand side and locks in the type. If you later try <code>inferredString = 99</code>, the compiler refuses -- the variable is permanently a <code>string</code>.</p><p>The four primitive types you&#8217;ll use in every React component:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qAYN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qAYN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 424w, https://substackcdn.com/image/fetch/$s_!qAYN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 848w, https://substackcdn.com/image/fetch/$s_!qAYN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 1272w, https://substackcdn.com/image/fetch/$s_!qAYN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qAYN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png" width="1000" height="338" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:338,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:59835,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/194108711?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qAYN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 424w, https://substackcdn.com/image/fetch/$s_!qAYN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 848w, https://substackcdn.com/image/fetch/$s_!qAYN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 1272w, https://substackcdn.com/image/fetch/$s_!qAYN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73f45edc-3725-4ff8-b236-362dfabbfcfe_1000x338.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><blockquote><p><strong>Watch out:</strong> Don&#8217;t annotate every variable explicitly. TypeScript&#8217;s inference is excellent -- use explicit annotations only for function parameters, return types, and complex objects.</p></blockquote><div><hr></div><h2><strong>Step 2: Interfaces and Type Aliases for Props</strong></h2><p>React component props are where TypeScript pays for itself fastest. Instead of guessing what a component expects, you define its contract as an interface, and the editor enforces it everywhere the component is used.</p><pre><code><code>// Interface for React component props
interface ButtonProps {
  label: string;
  onClick: () =&gt; void;
  disabled?: boolean;                          // ? means optional
  variant?: "primary" | "secondary" | "danger"; // Union type: one of these three strings
}

// Type alias (alternative syntax - functionally equivalent for objects)
type CardProps = {
  title: string;
  description: string;
  imageUrl?: string;
  tags: string[];   // array of strings
};

function Button({ label, disabled = false, variant = "primary" }: ButtonProps): string {
  return `&lt;button class="${variant}" disabled="${disabled}"&gt;${label}&lt;/button&gt;`;
}

function Card({ title, description, tags }: CardProps): string {
  return `&lt;div&gt;&lt;h2&gt;${title}&lt;/h2&gt;&lt;p&gt;${description}&lt;/p&gt;&lt;tags&gt;${tags.join(", ")}&lt;/tags&gt;&lt;/div&gt;`;
}
</code></code></pre><p><strong>Executed output:</strong></p><pre><code><code>=== Interface Example (ButtonProps) ===
&lt;button class="primary" disabled="false"&gt;Click Me&lt;/button&gt;
&lt;button class="danger" disabled="true"&gt;Disabled&lt;/button&gt;

=== Type Alias Example (CardProps) ===
&lt;div&gt;&lt;h2&gt;TypeScript Basics&lt;/h2&gt;&lt;p&gt;Learn TypeScript with React&lt;/p&gt;&lt;tags&gt;typescript, react, frontend&lt;/tags&gt;&lt;/div&gt;

&#10003; TypeScript catches type errors at compile time, not runtime!
</code></code></pre><p><strong>What just happened:</strong> When you call <code>Button({ label: 42, onClick: () =&gt; {} })</code>, TypeScript throws an error immediately: <code>Type 'number' is not assignable to type 'string'</code>. That error appears in your editor before you even run the code.</p><p><strong>Interface vs Type Alias -- which should you use?</strong></p><p>Both work. The community convention in React projects is to use <code>interface</code> for component props and <code>type</code> for everything else (union types, utility types, function signatures). Either is fine -- the important thing is to pick one and be consistent within a codebase.</p><div><hr></div><h2><strong>Step 3: Typing State with useState</strong></h2><p><code>useState</code> is a generic function -- it accepts a type parameter <code>&lt;T&gt;</code> that tells TypeScript what kind of value the state holds. When you provide the type, TypeScript ensures every <code>setState</code> call passes the correct shape.</p><pre><code><code>// useState&lt;T&gt; generic signature
const [count, setCount] = useState&lt;number&gt;(0);
const [name, setName] = useState&lt;string&gt;("");

// Object state with interface
interface User {
  id: number;
  name: string;
  email: string;
  isLoggedIn: boolean;
}

const [user, setUser] = useState&lt;User&gt;({
  id: 0,
  name: "",
  email: "",
  isLoggedIn: false,
});

// Array state
const [todos, setTodos] = useState&lt;string[]&gt;([]);
</code></code></pre><p><strong>Executed output (simulating React&#8217;s useState with TypeScript generics):</strong></p><pre><code><code>=== useState&lt;number&gt; ===
  Initial count: 0
  State updated to: 1
  State updated to: 5

=== useState&lt;string&gt; ===
  State updated to: "Alice"
  State updated to: "Bob"

=== useState&lt;User&gt; ===
  State updated to: {"id":1,"name":"Alice","email":"alice@example.com","isLoggedIn":true}

=== useState&lt;string[]&gt; ===
  State updated to: ["Buy groceries","Learn TypeScript","Build React app"]

&#10003; TypeScript generics enforce correct types for state updates!
</code></code></pre><p><strong>What just happened:</strong> TypeScript locks the type for every <code>setState</code> call. Calling <code>setCount("hello")</code> throws <code>Argument of type 'string' is not assignable to parameter of type 'number'</code> -- the compiler refuses before the browser ever sees it.</p><p>In practice, you often don&#8217;t need to write <code>useState&lt;number&gt;(0)</code> -- TypeScript infers <code>number</code> from the initial value <code>0</code>. The explicit generic becomes valuable when:</p><ol><li><p>The initial value is <code>null</code> but you know the type later: <code>useState&lt;User | null&gt;(null)</code></p></li><li><p>The initial value is an empty array: <code>useState&lt;string[]&gt;([])</code></p></li><li><p>The initial value is a complex union: <code>useState&lt;"idle" | "loading" | "done"&gt;("idle")</code></p></li></ol><blockquote><p><strong>Watch out:</strong> Avoid <code>useState&lt;any&gt;</code>. It defeats the entire purpose of TypeScript. If you&#8217;re tempted to use <code>any</code>, it usually means an interface is missing.</p></blockquote><div><hr></div><h2><strong>Step 4: Typing Event Handlers</strong></h2><p>Event handlers are one of the trickiest parts of React + TypeScript for beginners because the event types are long and specific. The rule is simple: look at which HTML element fires the event, then find the matching type.</p><pre><code><code>// React event handler type patterns
const handleInputChange = (event: React.ChangeEvent&lt;HTMLInputElement&gt;): void =&gt; {
  console.log(`Field "${event.target.name}" changed to: "${event.target.value}"`);
};

const handleButtonClick = (event: React.MouseEvent&lt;HTMLButtonElement&gt;): void =&gt; {
  event.preventDefault();
  console.log("Button clicked!");
};

const handleFormSubmit = (event: React.FormEvent&lt;HTMLFormElement&gt;): void =&gt; {
  event.preventDefault();
  // process form data
};
</code></code></pre><p><strong>Executed output:</strong></p><pre><code><code>=== Typed Event Handlers ===
  Field "email" changed to: "john@example.com"
  Field "username" changed to: "JohnDoe"
  Button clicked! Target text: "Submit Form"

=== React Event Type Reference ===
  onChange (input)       &#8594; React.ChangeEvent&lt;HTMLInputElement&gt;
  onClick (button)       &#8594; React.MouseEvent&lt;HTMLButtonElement&gt;
  onSubmit (form)        &#8594; React.FormEvent&lt;HTMLFormElement&gt;
  onKeyDown              &#8594; React.KeyboardEvent&lt;HTMLInputElement&gt;
  onDragStart            &#8594; React.DragEvent&lt;HTMLDivElement&gt;
</code></code></pre><p><strong>What just happened:</strong> Each event type gives you full autocomplete for the event&#8217;s properties. <code>React.ChangeEvent&lt;HTMLInputElement&gt;</code> knows about <code>.target.value</code>, <code>.target.name</code>, and <code>.target.checked</code>. Without the type, you&#8217;re guessing.</p><p><strong>Quick reference cheat sheet:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8mwr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8mwr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 424w, https://substackcdn.com/image/fetch/$s_!8mwr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 848w, https://substackcdn.com/image/fetch/$s_!8mwr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 1272w, https://substackcdn.com/image/fetch/$s_!8mwr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8mwr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png" width="1456" height="397" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:397,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:98095,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/194108711?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8mwr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 424w, https://substackcdn.com/image/fetch/$s_!8mwr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 848w, https://substackcdn.com/image/fetch/$s_!8mwr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 1272w, https://substackcdn.com/image/fetch/$s_!8mwr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b3d9a09-da0b-4231-9448-ee26cfe3282e_1476x402.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><h2><strong>Step 5: Generic Components and Utility Types</strong></h2><p>Once you&#8217;re comfortable with basic types, two TypeScript features unlock serious power: generic components (one component that works with any data shape) and utility types (tools for transforming existing types).</p><h3><strong>Generic Components</strong></h3><pre><code><code>// A generic List component that works with ANY data type
interface ListProps&lt;T&gt; {
  items: T[];
  renderItem: (item: T, index: number) =&gt; string;
  keyExtractor: (item: T) =&gt; string | number;
}

function List&lt;T&gt;({ items, renderItem, keyExtractor }: ListProps&lt;T&gt;): JSX.Element {
  return (
    &lt;ul&gt;
      {items.map((item, i) =&gt; (
        &lt;li key={keyExtractor(item)}&gt;{renderItem(item, i)}&lt;/li&gt;
      ))}
    &lt;/ul&gt;
  );
}
</code></code></pre><p><strong>Executed output -- same component, two completely different data types:</strong></p><pre><code><code>=== Generic List&lt;Product&gt; ===
[key=1] TypeScript Handbook - $29.99
[key=2] React Course - $49.99
[key=3] VS Code Extension - $9.99

=== Generic List&lt;BlogPost&gt; ===
[key=ts-intro] "TypeScript Intro" (8 min read)
[key=react-hooks] "React Hooks Guide" (12 min read)
</code></code></pre><h3><strong>TypeScript Utility Types</strong></h3><p>Utility types let you derive new types from existing ones without rewriting them from scratch. These are invaluable for API responses, form states, and props that share most but not all fields.</p><pre><code><code>interface UserFull {
  id: number;
  name: string;
  email: string;
  password: string;
  role: "admin" | "user" | "guest";
}

type UserPublic = Omit&lt;UserFull, "password"&gt;;         // Remove password field
type UserUpdate = Partial&lt;Omit&lt;UserFull, "id"&gt;&gt;;      // All fields optional except id
type UserCreate = Required&lt;Pick&lt;UserFull, "name" | "email" | "password"&gt;&gt;;
</code></code></pre><p><strong>Executed output:</strong></p><pre><code><code>=== TypeScript Utility Types ===
  UserFull:                  {"id":1,"name":"Alice","email":"a@b.com","password":"hashed","role":"admin"}
  UserPublic (no password):  {"id":1,"name":"Alice","email":"a@b.com","role":"admin"}
  UserUpdate (all optional): {"name":"Alice Updated"}
  UserCreate (required only):{"name":"Bob","email":"b@c.com","password":"hashed"}
</code></code></pre><p><strong>The 5 utility types every React developer should know:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!o2n_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!o2n_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 424w, https://substackcdn.com/image/fetch/$s_!o2n_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 848w, https://substackcdn.com/image/fetch/$s_!o2n_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 1272w, https://substackcdn.com/image/fetch/$s_!o2n_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!o2n_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png" width="936" height="410" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:410,&quot;width&quot;:936,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:75055,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/194108711?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!o2n_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 424w, https://substackcdn.com/image/fetch/$s_!o2n_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 848w, https://substackcdn.com/image/fetch/$s_!o2n_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 1272w, https://substackcdn.com/image/fetch/$s_!o2n_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f6004f5-68f3-4d3b-8d26-08179b743d6e_936x410.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><div><hr></div><h2><strong>Step 6: Null Safety and Discriminated Unions</strong></h2><p>TypeScript&#8217;s strictest (and most valuable) feature is null safety. With <code>"strict": true</code> in <code>tsconfig.json</code>, TypeScript forces you to handle every case where a value might be <code>null</code> or <code>undefined</code>. This eliminates the most common React crash: &#8220;Cannot read properties of null.&#8221;</p><pre><code><code>// Null-safe function
function getUserName(user: { name: string } | null): string {
  if (user === null) {
    return "Anonymous";  // TypeScript knows user is null here
  }
  return user.name;      // TypeScript knows user is NOT null here
}
</code></code></pre><p><strong>Executed output:</strong></p><pre><code><code>=== Null Safety ===
  With user:    "Alice"
  With null:    "Anonymous"
</code></code></pre><p>Discriminated unions are TypeScript&#8217;s answer to async state management in React. Instead of storing <code>isLoading</code>, <code>isError</code>, <code>data</code> as three separate booleans that can contradict each other, you model all states as a single union type:</p><pre><code><code>type LoadingState =
  | { status: "idle" }
  | { status: "loading" }
  | { status: "success"; data: string[] }
  | { status: "error"; message: string };

function renderState(state: LoadingState): string {
  switch (state.status) {
    case "idle":    return "Waiting to load...";
    case "loading": return "Loading...";
    case "success": return `Loaded ${state.data.length} items`;
    case "error":   return `Error: ${state.message}`;
  }
}
</code></code></pre><p><strong>Executed output:</strong></p><pre><code><code>=== Discriminated Unions (State Machine) ===
  [IDLE   ] Waiting to load...
  [LOADING] Loading...
  [SUCCESS] Loaded 3 items: [React, TypeScript, Vite]
  [ERROR  ] Error: Network timeout
</code></code></pre><p><strong>What just happened:</strong> TypeScript narrows the type inside each <code>case</code> branch. In <code>case "success"</code>, TypeScript knows <code>state.data</code> exists. In <code>case "error"</code>, it knows <code>state.message</code> exists. If you forget a case, TypeScript warns you -- a complete safety net for async UI states.</p><div><hr></div><h2><strong>Complete Source Code Reference</strong></h2><p>Here&#8217;s a complete, production-ready React + TypeScript component putting everything together:</p><pre><code><code>// src/components/UserList.tsx
import { useState } from "react";

// --- Types ---
interface User {
  id: number;
  name: string;
  email: string;
  role: "admin" | "user" | "guest";
}

type LoadingState =
  | { status: "idle" }
  | { status: "loading" }
  | { status: "success"; data: User[] }
  | { status: "error"; message: string };

interface UserCardProps {
  user: User;
  onDelete: (id: number) =&gt; void;
}

// --- Sub-component ---
function UserCard({ user, onDelete }: UserCardProps) {
  const handleDelete = (e: React.MouseEvent&lt;HTMLButtonElement&gt;) =&gt; {
    e.preventDefault();
    onDelete(user.id);
  };

  return (
    &lt;div className="user-card"&gt;
      &lt;h3&gt;{user.name}&lt;/h3&gt;
      &lt;p&gt;{user.email}&lt;/p&gt;
      &lt;span className={`role role--${user.role}`}&gt;{user.role}&lt;/span&gt;
      &lt;button onClick={handleDelete}&gt;Delete&lt;/button&gt;
    &lt;/div&gt;
  );
}

// --- Main component ---
export function UserList() {
  const [state, setState] = useState&lt;LoadingState&gt;({ status: "idle" });
  const [search, setSearch] = useState&lt;string&gt;("");

  const handleSearch = (e: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; {
    setSearch(e.target.value);
  };

  const fetchUsers = async () =&gt; {
    setState({ status: "loading" });
    try {
      const res = await fetch("/api/users");
      const data: User[] = await res.json();
      setState({ status: "success", data });
    } catch (err) {
      setState({ status: "error", message: "Failed to load users" });
    }
  };

  const handleDelete = (id: number) =&gt; {
    if (state.status !== "success") return;
    setState({
      status: "success",
      data: state.data.filter((u) =&gt; u.id !== id),
    });
  };

  // Render based on state
  if (state.status === "idle") {
    return &lt;button onClick={fetchUsers}&gt;Load Users&lt;/button&gt;;
  }

  if (state.status === "loading") {
    return &lt;p&gt;Loading...&lt;/p&gt;;
  }

  if (state.status === "error") {
    return &lt;p&gt;Error: {state.message}&lt;/p&gt;;
  }

  // TypeScript knows state.data exists here (status === "success")
  const filtered = state.data.filter((u) =&gt;
    u.name.toLowerCase().includes(search.toLowerCase())
  );

  return (
    &lt;div&gt;
      &lt;input
        type="text"
        value={search}
        onChange={handleSearch}
        placeholder="Search users..."
      /&gt;
      {filtered.map((user) =&gt; (
        &lt;UserCard key={user.id} user={user} onDelete={handleDelete} /&gt;
      ))}
    &lt;/div&gt;
  );
}
</code></code></pre><p><strong>Troubleshooting</strong></p><p>Here are the 5 most common TypeScript + React errors and exact fixes:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MzWH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MzWH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 424w, https://substackcdn.com/image/fetch/$s_!MzWH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 848w, https://substackcdn.com/image/fetch/$s_!MzWH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 1272w, https://substackcdn.com/image/fetch/$s_!MzWH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MzWH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png" width="1456" height="653" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:653,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:189000,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://nandigamharikrishna.substack.com/i/194108711?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MzWH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 424w, https://substackcdn.com/image/fetch/$s_!MzWH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 848w, https://substackcdn.com/image/fetch/$s_!MzWH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 1272w, https://substackcdn.com/image/fetch/$s_!MzWH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f4146bc-3e1c-47e1-8ee8-c7090200e8a7_1676x752.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div><hr></div><p><strong>Official resources:</strong></p><ul><li><p><a href="https://www.typescriptlang.org/docs/handbook/">TypeScript Handbook</a> -- the authoritative reference</p></li><li><p><a href="https://react-typescript-cheatsheet.netlify.app/">React TypeScript Cheatsheet</a> -- community-maintained quick reference</p></li><li><p><a href="https://github.com/DefinitelyTyped/DefinitelyTyped">DefinitelyTyped</a> -- <code>@types/*</code> packages for any library</p></li></ul><div><hr></div><h2><strong>Frequently Asked Questions</strong></h2><h3><strong>Do I need TypeScript to use React in 2026?</strong></h3><p>No -- React works perfectly with plain JavaScript. But TypeScript is worth learning early because it catches prop errors, null-reference crashes, and API shape mismatches at compile time. According to the 2025 Stack Overflow Survey, 78% of professional developers use TypeScript, so most teams you join will expect it. Starting with TypeScript is significantly easier than migrating a large JavaScript codebase later.</p><h3><strong>What&#8217;s the difference between </strong><code>interface</code><strong> and </strong><code>type</code><strong> in TypeScript?</strong></h3><p>Both <code>interface</code> and <code>type</code> define object shapes, and for React props they&#8217;re nearly interchangeable. The community convention is to use <code>interface</code> for component props and object definitions, and <code>type</code> for union types, function signatures, and utility type compositions. Interfaces support <code>extends</code> for inheritance; types support <code>&amp;</code> (intersection) for composition. Neither is strictly better -- pick one convention per codebase and stick to it.</p><h3><strong>How do I type a React component that accepts </strong><code>children</code><strong>?</strong></h3><p>Use <code>React.PropsWithChildren&lt;T&gt;</code> or add <code>children: React.ReactNode</code> to your interface manually. <code>React.ReactNode</code> is the broadest type -- it accepts strings, numbers, JSX elements, arrays, and null. For components that only accept a single element child, use <code>React.ReactElement</code>. Vite&#8217;s <code>react-ts</code> template and React 18+ no longer implicitly include <code>children</code> in <code>React.FC&lt;T&gt;</code>, so you must declare it explicitly.</p><pre><code><code>interface CardProps {
  title: string;
  children: React.ReactNode; // Accepts any renderable content
}

function Card({ title, children }: CardProps) {
  return &lt;div&gt;&lt;h2&gt;{title}&lt;/h2&gt;{children}&lt;/div&gt;;
}
</code></code></pre><h3><strong>When should I use </strong><code>any</code><strong> in TypeScript?</strong></h3><p>Almost never in React code. <code>any</code> disables all TypeScript checks for that value, defeating the purpose of the type system. If you&#8217;re reaching for <code>any</code>, use <code>unknown</code> instead (forces an explicit type check before use), or define a proper interface for the data shape. Legitimate uses: third-party library integrations without <code>@types/*</code> packages, and temporary migration code you plan to type properly within the same sprint.</p><h3><strong>How does TypeScript work with React&#8217;s </strong><code>useReducer</code><strong>?</strong></h3><p><code>useReducer</code> pairs perfectly with TypeScript&#8217;s discriminated unions. Type the action as a union (<code>type Action = { type: "increment" } | { type: "set"; value: number }</code>) and the reducer function as <code>(state: State, action: Action) =&gt; State</code>. TypeScript then narrows the action type inside each <code>case</code>, so you can&#8217;t accidentally access <code>.value</code> on an <code>"increment"</code> action.</p><p>[INTERNAL-LINK: useReducer deep dive &#8594; complete guide to state management patterns in React]</p><div><hr></div><h2><strong>Conclusion</strong></h2><p>TypeScript transforms React development from &#8220;hope the props are right&#8221; to &#8220;the compiler guarantees they&#8217;re right.&#8221; You&#8217;ve covered the full foundation: primitive types and inference, interfaces and type aliases for props, <code>useState</code> with generics, typed event handlers, generic components, utility types, and null safety with discriminated unions.</p><p>The most important habit to build: write the interface before writing the component. Defining the prop contract first forces you to think about the component&#8217;s API, catches integration errors early, and documents the component for your future self and teammates.</p><p>Start with <code>"strict": true</code> in your tsconfig from day one. It&#8217;s harder initially but produces far cleaner code than retrofitting strictness later.</p><p><strong>Where to go next:</strong></p><ul><li><p>Write a custom typed hook: <code>useLocalStorage&lt;T&gt;</code> is an excellent first exercise</p></li><li><p>Type your first API call with a proper <code>interface</code> matching the JSON response</p></li><li><p>Run <code>npx tsc --noEmit</code> in your project to see all current type errors</p></li></ul><div><hr></div><p><em>Tested with React 19, TypeScript 5.7, and Vite 6.</em></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Consistent Hashing Explained (With a Practical Python Example and Images)]]></title><description><![CDATA[Detailed breakdown of consistent hashing technique]]></description><link>https://nandigamharikrishna.substack.com/p/consistent-hashing-explained-with</link><guid isPermaLink="false">https://nandigamharikrishna.substack.com/p/consistent-hashing-explained-with</guid><dc:creator><![CDATA[Hari Krishna]]></dc:creator><pubDate>Wed, 11 Feb 2026 05:21:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!0t4k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0t4k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0t4k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 424w, https://substackcdn.com/image/fetch/$s_!0t4k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 848w, https://substackcdn.com/image/fetch/$s_!0t4k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 1272w, https://substackcdn.com/image/fetch/$s_!0t4k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0t4k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png" width="1456" height="797" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:797,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0t4k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 424w, https://substackcdn.com/image/fetch/$s_!0t4k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 848w, https://substackcdn.com/image/fetch/$s_!0t4k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 1272w, https://substackcdn.com/image/fetch/$s_!0t4k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e7b3efd-1e9f-440d-8af5-5f8d55fd4e2b_1600x876.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">credits: Google Nano Banana</figcaption></figure></div><p>Scaling distributed systems is easy in theory and painful in practice. One of the biggest challenges is figuring out what happens to your data when servers are added or removed. If a small infrastructure change causes massive data reshuffling, performance degrades quickly.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3APv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3APv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 424w, https://substackcdn.com/image/fetch/$s_!3APv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 848w, https://substackcdn.com/image/fetch/$s_!3APv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 1272w, https://substackcdn.com/image/fetch/$s_!3APv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3APv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png" width="1456" height="722" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4155170e-58c1-4572-879f-f759de404a57_1600x793.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:722,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3APv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 424w, https://substackcdn.com/image/fetch/$s_!3APv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 848w, https://substackcdn.com/image/fetch/$s_!3APv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 1272w, https://substackcdn.com/image/fetch/$s_!3APv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4155170e-58c1-4572-879f-f759de404a57_1600x793.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Consistent hashing exists to solve exactly this problem.</p><h3>What Is Consistent Hashing?</h3><p>Consistent hashing is a distributed hashing technique designed to minimize disruption when the number of servers in a system changes.</p><p>Instead of mapping data directly to servers, both data keys and servers are mapped onto the same logical circular space, often called a <em>hash ring</em>. Each key is assigned to the next available server in the clockwise direction on the ring.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!K6s7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!K6s7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 424w, https://substackcdn.com/image/fetch/$s_!K6s7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 848w, https://substackcdn.com/image/fetch/$s_!K6s7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 1272w, https://substackcdn.com/image/fetch/$s_!K6s7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!K6s7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png" width="1456" height="780" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:780,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!K6s7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 424w, https://substackcdn.com/image/fetch/$s_!K6s7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 848w, https://substackcdn.com/image/fetch/$s_!K6s7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 1272w, https://substackcdn.com/image/fetch/$s_!K6s7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67fd07ad-3f6e-4b84-b97f-83d0a1a45f85_1600x857.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The key insight is this:</p><p>When a server is added or removed, only a small subset of keys needs to be reassigned. Most of the system remains untouched.</p><p>This property makes consistent hashing especially valuable in large, dynamic systems.</p><h3>Why Traditional Hashing Falls Short</h3><p>In a na&#239;ve hashing approach, keys are often assigned using something like:</p><pre><code>hash(key) % number_of_servers</code></pre><p>The problem is that changing the number of servers invalidates almost every existing mapping. Even a single server addition can cause most keys to move.</p><p>Consistent hashing avoids this by making server membership changes local rather than global.</p><h3>How Consistent Hashing Works</h3><p>At a high level:</p><ol><li><p>Hash both servers and keys into the same numeric space.</p></li><li><p>Arrange them on a circular ring.</p></li><li><p>Assign each key to the first server encountered when moving clockwise.</p></li><li><p>When a server is added or removed, only nearby keys are affected.</p></li></ol><p>To improve load distribution, each physical server is represented by multiple <em>virtual nodes</em> (also called replicas) on the ring.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!suSa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!suSa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 424w, https://substackcdn.com/image/fetch/$s_!suSa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 848w, https://substackcdn.com/image/fetch/$s_!suSa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 1272w, https://substackcdn.com/image/fetch/$s_!suSa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!suSa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png" width="1456" height="780" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:780,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!suSa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 424w, https://substackcdn.com/image/fetch/$s_!suSa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 848w, https://substackcdn.com/image/fetch/$s_!suSa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 1272w, https://substackcdn.com/image/fetch/$s_!suSa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84d0d163-ebe4-47f0-8b22-9cc14fa115a9_1600x857.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MWyj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MWyj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 424w, https://substackcdn.com/image/fetch/$s_!MWyj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 848w, https://substackcdn.com/image/fetch/$s_!MWyj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 1272w, https://substackcdn.com/image/fetch/$s_!MWyj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MWyj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png" width="1456" height="877" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MWyj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 424w, https://substackcdn.com/image/fetch/$s_!MWyj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 848w, https://substackcdn.com/image/fetch/$s_!MWyj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 1272w, https://substackcdn.com/image/fetch/$s_!MWyj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdabccbd-5afe-4023-b6d0-ff4f4f3ce5b1_1600x964.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>A Simple Python Implementation</h3><p>Below is a minimal Python example that demonstrates the core mechanics of consistent hashing.</p><pre><code>import hashlib</code></pre><pre><code>class ConsistentHash:
    def __init__(self, nodes=None, replicas=3):
        self.replicas = replicas
        self.ring = {}
        self.nodes = []
        if nodes:
            for node in nodes:
                self.add_node(node)</code></pre><pre><code>    def _hash(self, key):
        return int(hashlib.md5(key.encode(&#8221;utf-8&#8221;)).hexdigest(), 16)</code></pre><pre><code>    def add_node(self, node):
        self.nodes.append(node)
        for i in range(self.replicas):
            key = f&#8221;{node}:{i}&#8221;
            self.ring[self._hash(key)] = node</code></pre><pre><code>    def remove_node(self, node):
        self.nodes.remove(node)
        for i in range(self.replicas):
            key = f&#8221;{node}:{i}&#8221;
            del self.ring[self._hash(key)]</code></pre><pre><code>    def get_node(self, key):
        if not self.ring:
            return None
        hashed_key = self._hash(key)
        sorted_keys = sorted(self.ring.keys())
        for node_hash in sorted_keys:
            if hashed_key &lt;= node_hash:
                return self.ring[node_hash]
        return self.ring[sorted_keys[0]]</code></pre><h3>Example Usage</h3><pre><code>nodes = [&#8221;server1&#8221;, &#8220;server2&#8221;, &#8220;server3&#8221;]
hash_ring = ConsistentHash(nodes)</code></pre><pre><code>print(hash_ring.get_node(&#8221;data1&#8221;))
print(hash_ring.get_node(&#8221;data2&#8221;))</code></pre><pre><code>hash_ring.add_node(&#8221;server4&#8221;)
print(hash_ring.get_node(&#8221;data3&#8221;))</code></pre><p>This implementation demonstrates:</p><ul><li><p>Virtual nodes for smoother distribution</p></li><li><p>Minimal key movement when a server is added</p></li><li><p>Ring wrap-around logic</p></li></ul><h3>Where Consistent Hashing Is Used</h3><h3>Distributed Caching</h3><p>Systems like Memcached and Redis clients use consistent hashing to distribute cached keys. When a cache node goes down, only a portion of the cache needs rebuilding.</p><h3>Database Sharding</h3><p>Consistent hashing helps distribute data shards evenly and reduces rebalancing costs during scaling.</p><h3>Load Balancing</h3><p>It enables request routing with session affinity, ensuring that the same client consistently hits the same backend server.</p><h3>Common Mistakes to Avoid</h3><p><strong>Skipping virtual nodes</strong></p><p>Without replicas, load distribution can be highly uneven.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2vwD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2vwD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 424w, https://substackcdn.com/image/fetch/$s_!2vwD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 848w, https://substackcdn.com/image/fetch/$s_!2vwD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 1272w, https://substackcdn.com/image/fetch/$s_!2vwD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2vwD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png" width="1456" height="836" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:836,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2vwD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 424w, https://substackcdn.com/image/fetch/$s_!2vwD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 848w, https://substackcdn.com/image/fetch/$s_!2vwD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 1272w, https://substackcdn.com/image/fetch/$s_!2vwD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4e79226-67cb-4fb9-b12c-c3bf560d59bd_1600x919.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dagh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dagh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 424w, https://substackcdn.com/image/fetch/$s_!dagh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 848w, https://substackcdn.com/image/fetch/$s_!dagh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 1272w, https://substackcdn.com/image/fetch/$s_!dagh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dagh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png" width="1456" height="901" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:901,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dagh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 424w, https://substackcdn.com/image/fetch/$s_!dagh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 848w, https://substackcdn.com/image/fetch/$s_!dagh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 1272w, https://substackcdn.com/image/fetch/$s_!dagh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5ccc51ed-0634-48c0-87c7-4ebcdef3fc8f_1600x990.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Using weak hash functions</strong></p><p>Poor hashing leads to clustering and hotspots. Always use a well-distributed hash function.</p><p><strong>Ignoring node capacity</strong></p><p>Not all servers are equal. More powerful nodes should receive more virtual nodes to reflect their capacity.</p><h3>Best Practices</h3><ul><li><p>Use a strong, well-distributed hash function.</p></li><li><p>Always implement virtual nodes.</p></li><li><p>Adjust replica counts based on node capacity.</p></li><li><p>Monitor key distribution and rebalance when needed.</p></li><li><p>Automatically remove unhealthy nodes from the ring.</p></li></ul><h3>A Practical Exercise</h3><p>Extend the implementation to track load distribution.</p><p>Try adding:</p><ul><li><p>A method that counts how many keys map to each node</p></li><li><p>A simple text-based histogram to visualize imbalance</p></li></ul><p>This exercise reinforces how virtual nodes and capacity tuning affect real-world systems.</p><h3>Related Concepts</h3><ul><li><p>Load balancing</p></li><li><p>Distributed caching</p></li><li><p>Database sharding</p></li></ul><p>If you understand consistent hashing, these topics become much easier to reason about.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3d2F!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3d2F!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 424w, https://substackcdn.com/image/fetch/$s_!3d2F!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 848w, https://substackcdn.com/image/fetch/$s_!3d2F!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 1272w, https://substackcdn.com/image/fetch/$s_!3d2F!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3d2F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png" width="1456" height="772" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:772,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3d2F!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 424w, https://substackcdn.com/image/fetch/$s_!3d2F!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 848w, https://substackcdn.com/image/fetch/$s_!3d2F!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 1272w, https://substackcdn.com/image/fetch/$s_!3d2F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96336060-81d9-4023-93ca-85b6098ec5d1_1600x848.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Final Thought</h3><p>Consistent hashing is one of those concepts that feels abstract at first but becomes indispensable once systems grow. It&#8217;s not about perfect distribution&#8202;&#8212;&#8202;it&#8217;s about graceful change.</p><p>If you expect your system to scale, consistent hashing is mandatory.</p><p>Image credits: Google Nano Banana</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://nandigamharikrishna.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Tech in General! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item></channel></rss>