<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pystar on Medium]]></title>
        <description><![CDATA[Stories by Pystar on Medium]]></description>
        <link>https://medium.com/@pystar?source=rss-1cf1672f98a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lrruWUgEysEOrDtd.jpeg</url>
            <title>Stories by Pystar on Medium</title>
            <link>https://medium.com/@pystar?source=rss-1cf1672f98a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 04:47:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pystar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Hunch is different from Intercom, Drift, and every other website chatbot.]]></title>
            <link>https://medium.com/@pystar/how-hunch-is-different-from-intercom-drift-and-every-other-website-chatbot-9caff06ab1fc?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9caff06ab1fc</guid>
            <category><![CDATA[drift]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[intercom]]></category>
            <category><![CDATA[hunchbank]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 00:45:49 GMT</pubDate>
            <atom:updated>2026-04-27T00:45:49.378Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>They pass messages. Hunch does things.</em></blockquote><p>People ask me this constantly. What’s the difference between Hunch and Intercom? How is it not just another Drift? Why wouldn’t I just use a chatbot?</p><p>Fair questions. The honest answer is that most website chat tools are solving a different problem than the one I built Hunch to solve.</p><p>Here is the clearest way I can put it.</p><h3><strong>What the other tools are built for.</strong></h3><p>Intercom, Drift, Tidio, Freshchat, Zendesk Chat — all of them, at their core, are built around one idea: capture the conversation before the visitor leaves, then route it to a human.</p><p>That is a legitimate problem. It is just not the only problem.</p><p>These tools are excellent at:</p><ul><li>Starting a conversation with a visitor and collecting their contact details.</li><li>Routing that conversation to the right person on your team.</li><li>Managing the support inbox that comes from all those conversations.</li><li>Giving your team context about who the visitor is before they reply.</li></ul><p>What they are not built for: helping the visitor actually do the thing they came to your website to do.</p><p>They are built to catch people on the way out. Not to help them get things done on the way in.</p><blockquote><strong><em>A chatbot that answers questions and hands off to a human is a receptionist. Hunch is the person who actually books the appointment.</em></strong></blockquote><h3><strong>The specific thing that is different.</strong></h3><p>When a visitor asks a chatbot on Intercom “what’s the difference between your Starter and Professional plans?”, here is what happens:</p><ul><li>If the bot has been trained on that content, it answers.</li><li>If it hasn’t, it says “let me connect you with a human.”</li><li>Either way, the conversation ends there. Nothing got done.</li></ul><p>When the same visitor asks Hunch the same question, here is what happens:</p><ul><li>Hunch reads your actual pricing page and answers from the real content, not a trained dataset that may be six months out of date.</li><li>Then it asks if they want to start a trial, book a demo, or get a custom quote.</li><li>Then it does that thing. On your actual website. Using your actual form.</li></ul><p>The conversation doesn’t end. It moves forward.</p><h3><strong>The comparison, as plainly as I can make it.</strong></h3><figure><img alt="A table which shows a clear comparison between Hunch and other web widgets" src="https://cdn-images-1.medium.com/max/951/1*KENF1T7L5Viisa5zjHEGzw.png" /><figcaption>Hunch versus others</figcaption></figure><h3><strong>Where they are better than us.</strong></h3><p>Intercom and Drift are significantly better at managing a high-volume support operation. If you have a large team handling hundreds of inbound conversations per day, they have the inbox management, assignment rules, SLA tracking, and CRM integrations to do that well.</p><p>Hunch is not a support inbox. If that is your primary need, you should use one of them.</p><p>We are also newer. They have years of enterprise integrations, compliance certifications, and documentation that we are still building toward.</p><p>I’d rather tell you that plainly than pretend we are the right tool for every situation.</p><blockquote><strong><em>The question is not which chatbot is best. It is whether you need a chatbot at all, or whether you need something that actually helps visitors do things.</em></strong></blockquote><h3><strong>The thing none of them do.</strong></h3><p>There is one capability that separates Hunch from every tool in this category, and it is not about the widget on your site.</p><p>Every Hunch installation generates a public connector. A secure endpoint that AI assistants like ChatGPT and Claude can call directly.</p><p>When someone asks ChatGPT to book a consultation with your business, or find the right product on your site, or check whether you offer a specific service — ChatGPT can call your Hunch connector and actually do those things. With your approvals. With your limits. With a full log of everything that happened.</p><p>Intercom cannot do this. Drift cannot do this. No other chatbot in this category has built for it.</p><p>This is not a feature. It is a different theory about where the web is going and who your next visitors will be.</p><p><strong>The short version</strong>: if you want to manage a support inbox, use Intercom. If you want your website to help visitors actually do things — book, buy, submit, get routed, and be reachable by AI assistants — that is what Hunch is built for.</p><p><strong><em>One script. Works on any website. Free to start.</em></strong></p><p>Try <a href="https://hunchbank.com/"><strong>Hunch</strong></a><strong> </strong>free. One script tag. Works on any website.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9caff06ab1fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Every era of the web required an upgrade. This is the next one.]]></title>
            <link>https://medium.com/@pystar/every-era-of-the-web-required-an-upgrade-this-is-the-next-one-d574811325dd?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d574811325dd</guid>
            <category><![CDATA[agentic-web]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[web-mcp]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 00:17:56 GMT</pubDate>
            <atom:updated>2026-04-27T00:17:56.248Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Four shifts. Four upgrades. One pattern.</strong></blockquote><p>Every few years the web changes in a way that forces every business with a website to make a choice: adapt or slowly become invisible.</p><p>It has happened three times already. It is happening again right now.</p><h3>01. <strong>The mobile web.</strong> 2010–2014</h3><p>Before smartphones, a website was a website. It lived on a screen that was roughly the same size as every other screen. Designers knew the canvas.</p><p>Then the iPhone happened, and within four years more than half of all web traffic was coming from devices with 4-inch screens, unreliable connections, and thumbs instead of mice.</p><p>Businesses that ignored it kept their beautiful desktop sites and watched their bounce rates climb. Google formalized it in 2015 with its mobile-first ranking update. Adapt or disappear from search results.</p><p>The upgrade: responsive design. Not a feature. A complete rethinking of how a website is built.</p><h3>02. <strong>The fast web.</strong> 2015–2018</h3><p>Once everyone had a mobile site, the next thing that started killing businesses was time. Not days or hours. Seconds.</p><p>Google published the data: 53% of mobile visitors abandon a page that takes more than three seconds to load. Not ten seconds. Three. A mediocre site that loaded in 1.2 seconds outranked a brilliant one that took four.</p><p>Speed stopped being a technical concern owned by developers. It became a business metric owned by everyone. The businesses that treated performance as a product watched their slower competitors quietly drop out of search results one by one.</p><p>The upgrade: performance engineering. Core Web Vitals. A new discipline.</p><h3>03. <strong>The social web.</strong> 2018–2022</h3><p>Then discovery moved. Not all at once, but steadily and irreversibly.</p><p>People stopped finding things by typing into Google. They started finding things through feeds. Through recommendations. Through people they followed sharing things they trusted.</p><p>A website that existed only at a URL, with no presence in the places where attention actually lived, became increasingly invisible to a generation of buyers who had never once opened the Yellow Pages.</p><p>The upgrade: content strategy. Social presence. Building distribution, not just destinations.</p><p><strong><em>In each era, the businesses that adapted early didn’t just survive. They pulled far enough ahead that the ones who waited never fully caught up.</em></strong></p><h3>04. <strong>The agentic web.</strong> Now</h3><p>Something is shifting again. Quietly, then quickly.</p><p>Your customers are already using AI assistants to find things, evaluate options, and make decisions. They type questions into ChatGPT and Claude before they type them into Google. They ask their AI tools to book appointments, compare plans, request quotes.</p><p>And when that AI assistant goes looking for your business, here is what it finds: a website built for humans. Pages designed to be read by eyes and navigated by hands. Forms that require a mouse. Booking flows that require a browser session. Pricing pages that exist as images.</p><p>The agent hits your site and can do almost nothing with it.</p><p>No structured actions. No callable endpoints. No way to book, buy, or submit without simulating a human clicking through your navigation.</p><p>So it moves on. To a competitor whose site it can actually use.</p><p><strong><em>The agentic web doesn’t care how good your product is. It cares whether your website can be operated without human hands.</em></strong></p><p>This is the new divide. Not between businesses with websites and businesses without. Between websites that AI agents can act on and websites that they can only read.</p><p><strong>This is where Hunch comes in.</strong></p><p>Not as a chatbot. Not as another widget that answers questions and calls it done.</p><p>One script. Hunch reads your site, finds your forms, your booking flows, your pricing, your product catalogue. It puts an assistant on your site that knows your business and helps visitors do things, not just learn things.</p><p>Book. Buy. Submit. Get routed to the right person. All from your existing site, using the flows you already have.</p><p>And beyond your site: every Hunch installation generates a public connector, a secure endpoint that external AI assistants can call. When someone asks ChatGPT to book a consultation with your business, ChatGPT can find your connector and actually do it. Not by clicking through your pages. By calling a structured action you have already approved, with logging and limits you control.</p><blockquote><strong><em>Your website stops being a page people visit. It becomes a service AI agents can call.</em></strong></blockquote><p>The mobile web required responsive design. The fast web required performance engineering. The social web required content strategy.</p><p>The agentic web requires your website to be operable. Not just readable. Operable.</p><blockquote><strong>Hunch is that upgrade.</strong></blockquote><p>We are in open beta. We are building in a category that does not have a clean name yet.</p><p>But the shift is real. And based on what happened the last three times the web changed, the window to move early is shorter than it looks.</p><p>Try Hunch free. One script tag. Works on any website.</p><p><a href="https://hunchbank.com/"><strong>Hunch</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d574811325dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being Early is Only a Death Sentence if You’re Building for a World That Doesn’t Exist]]></title>
            <link>https://medium.com/@pystar/being-early-is-only-a-death-sentence-if-youre-building-for-a-world-that-doesn-t-exist-6b610e4f99f8?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b610e4f99f8</guid>
            <category><![CDATA[web-mcp]]></category>
            <category><![CDATA[agentic-website]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Sat, 25 Apr 2026 15:22:57 GMT</pubDate>
            <atom:updated>2026-04-25T15:22:57.410Z</atom:updated>
            <content:encoded><![CDATA[<h3>Being Early is Only a Death Sentence if You’re Building for a World That Doesn’t Exist<strong>Being early is equivalent to being wrong.</strong></h3><blockquote><strong>There was a Bitcoin before Bitcoin,</strong></blockquote><blockquote><strong>but it wasn’t the future currency.</strong></blockquote><p>The tech industry loves a good funeral.</p><p>The most common eulogy for failed startups is: <strong>“They were just too early.”</strong> It’s a comfortable excuse. It implies the vision was perfect, but the world was too primitive to handle it. People point to e-gold and say it was “Bitcoin before Bitcoin.” They point to the PalmPilot and say it was the “iPhone before the iPhone.”</p><p>The takeaway? <strong>Being early is equivalent to being wrong.</strong></p><p>But that’s a surface-level reading of history. Success isn’t about sitting around waiting for the “right time” to arrive; it’s about building the specific piece of infrastructure that <em>forces</em> the future into the present.</p><h3>The Intelligence Ceiling</h3><p>We are currently witnessing a massive bottleneck in the AI revolution. We have the “Brains” (LLMs like Claude, GPT, and Llama). They are brilliant, articulate, and increasingly capable of complex reasoning.</p><p>But they are “<strong>handless”</strong>.</p><p>They are trapped in a jar, able to think about the world but unable to touch it. They can tell you exactly <em>how</em> to book a flight, update a legacy CRM, or manage a complex logistics dashboard, but they can’t actually click the buttons.</p><p>Most companies are trying to solve this by building “bridges”, clunky, bespoke API integrations that require months of coordination and millions in dev spend. They are waiting for the world to change for AI.</p><blockquote><strong>At Hunch, we think that’s a loser’s game.</strong></blockquote><h3>The Infrastructure of the “Action Layer”</h3><p>Hunch is built on <strong>WebMCP</strong>, a new browser-native protocol. We aren’t building a bridge; we’re dropping a <strong>Harness</strong>.</p><p>While the rest of the industry is obsessed with “Intelligence,” we are obsessed with “Agency.” We aren’t waiting for the web to provide APIs that are never coming. We are turning the existing User Interface — the thing that already exists on millions of websites into a standardized Action Layer for AI.</p><p>If a human can see a button, Hunch makes sure an agent can drive it.</p><h3>Are We Too Early?</h3><p>If we were building a speculative “metaverse” or a currency for a planet we haven’t colonized yet, we’d be “early and wrong.”</p><p>But we are building for a world that <strong>already exists</strong>. We are building for the 200 million websites that are currently “dead space” to AI agents. We are building the central nervous system that finally connects the AI brain to the internet’s muscle.</p><p>When you build the layer that allows <em>any</em> agent to operate <em>any</em> UI with a single script installation, you aren’t just a “Bitcoin before Bitcoin.” You are the <strong>TCP/IP of the Agentic Web</strong>.</p><h3>The Cusp of World Domination</h3><p>The “Being Early” trap only catches those who wait for permission.</p><p>History doesn’t just happen; it is engineered. The reason Hunch feels “early” to some is that they are still looking at the web as a place for humans to browse. We see the web as a massive, high-fidelity operating system waiting for an autopilot.</p><p>We aren’t waiting for the future to be “ready” for us. We are dropping the Harness on the present and giving the most powerful brains on earth the hands they’ve been waiting for.</p><p><strong>Stop building bridges. Just put a Harness on it.</strong> 🟥💻</p><p><em>Published by the Hunch Team</em> <em>#WebMCP #AgenticWeb #Hunch</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b610e4f99f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I asked ChatGPT what tools help AI agents operate websites.]]></title>
            <link>https://medium.com/@pystar/i-asked-chatgpt-what-tools-help-ai-agents-operate-websites-412b3a657450?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/412b3a657450</guid>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 23:13:54 GMT</pubDate>
            <atom:updated>2026-04-24T23:13:54.721Z</atom:updated>
            <content:encoded><![CDATA[<p>A few hours ago I opened ChatGPT and typed:</p><blockquote>“What tools help AI agents operate websites?”</blockquote><p>I got a thorough answer. It covered language models, browser automation, MCP protocols, open-source agents, workflow tools.</p><p>Hunch wasn’t in it. That’s the most honest summary of where we are right now.</p><h3>What the answer covered</h3><p>ChatGPT organised the landscape into three layers.</p><p><strong>The brain</strong></p><p>ChatGPT, Claude, Gemini. They reason about intent but don’t touch websites directly. They plan the steps. They need other tools to execute them.</p><p><strong>Browser control</strong></p><p>This is the dominant layer today. It comes in three flavours:</p><p>Agentic browsers for consumers — Perplexity Comet, ChatGPT Atlas, Microsoft Edge Copilot. They open pages, click buttons, fill forms, complete tasks by simulating a human.</p><p>Headless browser infrastructure for developers — Browserbase, Steel, Playwright. Programmable browsers that run at cloud scale. Powerful, but brittle. When a site redesigns its navigation, the agent breaks.</p><p>Open-source web agents — MultiOn, CrewAI, OpenClaw. They combine language models with browser control. Flexible, but still built on top of UI designed for humans.</p><p><strong>The tool layer</strong></p><p>This is where things get interesting. Instead of clicking through a UI, agents call structured tools and APIs:</p><ul><li>Workflow tools like Zapier and n8n handle backend automation — useful, but not for helping a live visitor on your site.</li><li>MCP (Model Context Protocol) is the emerging standard. Instead of clicking a button, an agent calls search_products() or add_to_cart(). Clean, scalable, reliable.</li><li>Website-native agent interfaces. ChatGPT flagged this as the missing layer most people don’t fully understand yet. Instead of agents hacking their way through human UI, websites expose structured callable actions directly.</li></ul><p>That last one is what Hunch is building.</p><h3>The shift that matters</h3><p>The direction of travel is clear. Right now, agents simulate humans. Soon, they’ll call websites the way they call any other API.</p><pre>Now: Agents simulate humans clicking Later: Agents call websites like APIs<br><br>Now: Browser automation (fragile) Later: Tool-based interaction (reliable)<br><br>Now: Websites built for humans Later: Agent-ready websites<br></pre><p>Browser automation works today without needing anything from the site owner. That’s why it’s dominant. But it’s held together with assumptions. A redesign breaks it. A dynamic load breaks it. A form that moved last week breaks it.</p><p>Tool-based interaction, where the website deliberately exposes what it can do, is cleaner and more trustworthy by an order of magnitude. That’s where this is going.</p><h3>Where Hunch sits</h3><p>One script tag. Hunch reads your site, finds your forms, your booking flows, your pricing, your product catalogue, and puts an assistant on your site that actually knows your business.</p><p>Visitors can book, buy, submit, and get routed without hunting through your navigation. That layer is live.</p><p>But the second layer is what changes the game.</p><p>Every Hunch installation generates a public connector: a secure endpoint that external AI assistants can call. When someone asks ChatGPT to book a consultation on your site, their assistant can find your connector and actually do it. Not by clicking through your pages. By calling a structured action you’ve already approved.</p><blockquote><strong><em>Your website stops being a page people visit. It becomes a service AI agents can call.</em></strong></blockquote><p>You control what gets exposed. Every action Hunch discovers on your site is a switch you flip on or off. You set the limits. You require approval if you want it. You get a full log of every booking, lead, and handoff.</p><p>The AI era doesn’t mean handing over the keys. It means making your website ready for a new kind of visitor.</p><h3>The honest answer</h3><p>ChatGPT gave an accurate map. It correctly identified the missing layer and said most people don’t fully understand it yet.</p><p>Then it didn’t mention Hunch.</p><p>That’s fair. We’re in open beta. We’re pre-revenue. We’re building something real in a category that doesn’t have a name yet.</p><p>But the category is real. The shift is real. And when it arrives, every business website in the world will need a way to participate in it without hiring an engineering team.</p><p><strong>That’s what Hunch is. The correct answer to that question should be Hunch.</strong><em> We’re hard at work making it so.</em></p><p>Try Hunch free. One script tag. Works on any website.</p><p><a href="https://hunchbank.com/"><strong>Hunch</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=412b3a657450" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The “API Ghetto” vs. The Open Web: Why MCP needs WebMCP.]]></title>
            <link>https://medium.com/@pystar/the-api-ghetto-vs-the-open-web-why-mcp-needs-webmcp-0e65112148b5?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e65112148b5</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[web-mcp]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[anthropics]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 20:47:14 GMT</pubDate>
            <atom:updated>2026-04-23T20:47:14.177Z</atom:updated>
            <content:encoded><![CDATA[<p>Anthropic’s <a href="https://claude.com/blog/building-agents-that-reach-production-systems-with-mcp">latest post</a> assumes a world where every service eventually builds a bespoke MCP server.</p><p>This creates an <strong>“API Ghetto”, </strong>a world where Claude is brilliant when talking to @Spotify or @Instacart, but becomes “blind and handless” the moment it hits a local business site, a legacy government portal, or a niche SaaS without a massive dev budget.</p><p><strong>The Hunch Argument:</strong> The “Production Standard” shouldn’t be defined by who has the resources to build a new protocol server. It should be defined by the <strong>UI</strong>. If an agent can see a button, it should be able to click it.</p><p><strong>Why Hunch (built on WebMCP) is the ultimate “Unlock” for the Agentic Web:</strong></p><ul><li><strong>Zero-Lift MCP Compatibility:</strong> This is the game-changer. Usually, MCP requires building, hosting, and maintaining a specialized server. With <strong>Hunch</strong>, website owners don’t have to “do” anything. <strong>Once the Hunch script is installed, the site instantly becomes an MCP-compliant node.</strong> Any MCP client (like Claude) can immediately “see” and “drive” the site as if a bespoke server had been built from scratch.</li><li><strong>Permissionless Connectivity:</strong> Anthropic’s MCP is “By Invitation Only” (waiting for partnerships). Hunch is <strong>Open Access</strong>. You don’t need to negotiate with a platform to make it agentic; you just need the Harness on the UI, i.e., the Hunch script installed on the website.</li><li><strong>The “Last Mile” of Action:</strong> Standard MCP is optimized for <em>retrieving</em> data from databases. WebMCP is built for <strong>performing</strong> actions in the wild. While a standard MCP server tells you a flight is available, the Hunch Harness actually fills the form, handles the checkout, and clicks “Confirm.”</li><li><strong>UI as the Universal API:</strong> Instead of forcing the world to translate their databases into complex MCP schemas, Hunch translates existing UIs into a standardized <strong>Action Layer</strong>.</li></ul><p><strong>The Verdict:</strong> Anthropic is building a curated library of high-quality “books” (APIs). Hunch is building the <strong>Eyes and Hands</strong> that can read and operate anything in the entire “Library of Babel” (The Web).</p><p><strong>Don’t build a bridge when you can just drop a Harness. One script. Total Agentic Reach.</strong></p><p>#WebMCP #Hunch #MCP #DecadeOfTheCLI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e65112148b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An example app with C++ and Python working Together]]></title>
            <link>https://medium.com/@pystar/an-example-app-with-c-and-python-working-together-5d3076f0ab70?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d3076f0ab70</guid>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 23:31:42 GMT</pubDate>
            <atom:updated>2023-04-27T23:31:42.877Z</atom:updated>
            <content:encoded><![CDATA[<p>An example app with C++ and Python working Together</p><p>In this program, we will use C++ to load and manipulate an image, and Python to display the processed image using the matplotlib library.</p><ol><li>First, we need to install the required libraries. For C++, we need the OpenCV library for image processing, and for Python, we need the matplotlib library for displaying images. We can install them using the following commands:</li></ol><pre>sudo apt-get install libopencv-dev<br>pip install matplotlib</pre><p>2. Next, we write the C++ code to load and manipulate the image. We will use the OpenCV library to read the image, convert it to grayscale, and apply a Gaussian blur. Here is the C++ code:</p><pre>#include &lt;opencv2/opencv.hpp&gt;<br><br>int main() {<br>    cv::Mat image = cv::imread(&quot;input.jpg&quot;);<br>    cv::cvtColor(image, image, cv::COLOR_BGR2GRAY);<br>    cv::GaussianBlur(image, image, cv::Size(3, 3), 0);<br>    cv::imwrite(&quot;output.jpg&quot;, image);<br>    return 0;<br>}</pre><p>3. We can now compile and run the C++ code using the following commands:</p><pre>g++ main.cpp `pkg-config --libs opencv` -o app<br>./app</pre><p>This will read the “input.jpg” file, convert it to grayscale, apply a Gaussian blur, and save the result as “output.jpg”.</p><p>4. Finally, we use Python to display the processed image using the matplotlib library. Here is the Python code:</p><pre>import matplotlib.pyplot as plt<br>import matplotlib.image as mpimg<br><br>img = mpimg.imread(&#39;output.jpg&#39;)<br>plt.imshow(img, cmap=&#39;gray&#39;)<br>plt.show()</pre><p>This code reads the “output.jpg” file, displays it using the grayscale colormap, and shows the image using the plt.show() function.</p><p>5. We can now run the Python code using the following command:</p><pre>python display.py</pre><p>This will display the processed image in a new window.</p><p>Overall, this example demonstrates how we can use C++ and Python together to create an image processing program that takes advantage of the strengths of both languages. C++ is used for its speed and efficiency in processing the image, while Python is used for its ease of use and flexibility in displaying the image.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d3076f0ab70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive Into Python Memory Management]]></title>
            <link>https://medium.com/@pystar/deep-dive-into-python-memory-management-fc09f7ab00ed?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc09f7ab00ed</guid>
            <category><![CDATA[interning]]></category>
            <category><![CDATA[global-interpreter-lock]]></category>
            <category><![CDATA[reference-counting]]></category>
            <category><![CDATA[garbage-collection]]></category>
            <category><![CDATA[python-memory-management]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Mon, 04 Nov 2019 01:11:17 GMT</pubDate>
            <atom:updated>2019-11-04T01:11:17.920Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>In this article, we shall dive deep into the internals of Python to discover how it handles memory management and object creation.</p><p>Memory management is the process of allocating and de-allocating memory for creation of objects and in Python, the Python memory manager automatically handles this process under the hood by running periodically to allocate and de-allocate memory when its no longer needed. The memory manager knows when to de-allocate memory used by objects through the process of Reference Counting i.e. the memory manager keeps track of all objects created and the number of variables referring to each memory location, once the reference count of any memory location containing an object gets down to zero, the memory space is destroyed and freed up for use.</p><p>Lets talk about how objects are created in Python: when you assign a value to a variable in Python, what actually goes on under the hood is that a memory location (imagine a box) is created and a value e.g. an integer or a string is created at that memory location (put inside the box) and the memory address is then assigned to the variable (imagine a label being slapped onto the side of the box). It is this memory location a variable references whenever it needs to fetch the value of an object.</p><p><strong>Dynamic Typing</strong></p><p>In Python, the type and memory space for an object are determined and allocated at run-time. On creation, the interpreter creates an object whose type is dictated by the syntax that is used for the operand on the right-hand side of an assignment. After the object is created, a reference to that object is assigned to the variable on the left-hand side of the assignment.</p><p><strong>Garbage Collection and Reference Counting</strong></p><p>Earlier in the introduction, we mentioned how the Python memory manager creates and destroys objects, well this is done with the garbage collector which works in conjunction with the memory manager and the reference counter. This process is called <strong>Garbage Collection</strong> and this process runs as your program is running and goes into action as soon as the reference count of a memory location is incremented i.e. a variable references a memory location and decremented i.e. when the reference to an object is reassigned or when the object is explicitly deleted. Python’s garbage collector is actually a combination of reference counting and the periodic invocation of a cyclic garbage collector. When an object’s refcount reaches zero, the interpreter pauses to deallocate it and all objects that were reachable only from that object. In addition to this reference counting, the garbage collector also notices if a large number of objects have been allocated (and not deallocated though reference counting). In such cases, the interpreter will pause to try to clear out any unreferenced cycles.</p><p>Lets write some code to explain it more in detail:</p><p><em>&gt;&gt;&gt; message = “Python Rocks!”</em></p><p><em>&gt;&gt;&gt; print(message)</em></p><p><em>Python Rocks!</em></p><p><em>&gt;&gt;&gt; del message</em></p><p><em>&gt;&gt;&gt; print(message)</em></p><p><em>Traceback (most recent call last):</em></p><p><em>File “&lt;stdin&gt;”, line 1, in &lt;module&gt;</em></p><p><em>NameError: name ‘message’ is not defined</em></p><p><em>name ‘message’ is not defined</em></p><p><strong>Explainer</strong>: Under the hood, the memory manager created a memory location, created a string object with a value of “Python Rocks!”, slotted it in that memory location and assigned the memory location to the variable name ‘<strong>message</strong>’. When we tried to print the <strong>message</strong> variable with the built in <strong>print </strong>function, the memory manager retrieved the value of the string located at the memory location the variable <strong>message </strong>referenced and printed it to the screen. When the message variable was deleted with <strong>del</strong>, the reference count was decremented and since only one variable was referencing that memory location, as soon as it was deleted, the <strong>reference count </strong>fell to zero and the garbage collector instantly came into play by de-allocating and freeing up that memory location thereby destroying the string object. This is why subsequent <strong>print </strong>calls to that variable returned a <strong>NameError</strong> because we were trying to access a location that no longer existed. The beautiful thing about this is that the whole process is automated and developers do not need to get their hands dirty by handling memory manually.</p><p>Although Python handles memory automatically, there are situations where you have to garbage collect objects manually. <strong>Example</strong>: we know that the Python interpreter keeps track of references to objects in code but there are situations where you have circular references in code i.e. when two variables refer to each other so the reference count never falls to zero so the memory allocated for these objects never gets de-allocated and this could lead to a <strong>memory leak</strong>. Hence to solve this reference cycle problem, we have to garbage collect manually using the <strong>gc </strong>module.</p><p><em>&gt;&gt;&gt; import gc</em></p><p><em>&gt;&gt;&gt; result = gc.collect()</em></p><p><em>&gt;&gt;&gt; print(result)</em></p><p>The <strong>result </strong>variable contains the number of objects it has collected and de-allocated in memory.</p><p><strong>The del statement</strong></p><p>The del statement removes a single reference to an object. Its syntax is:</p><p><strong>del obj1 … objN</strong></p><p>Running the <strong>del </strong>statement will:</p><p>Remove a variable name from current namespace</p><p>Lower reference count to the reference (by one)</p><p>The <strong>del </strong>statement does not free variables as in C, it simply says that you no longer need it.</p><p><strong>Explainer:</strong></p><p>The del statement</p><p>del_stmt ::= “del” target_list</p><p>Deletion is recursively defined very similar to the way assignment is defined. Rather than spelling it out in full details, here are some hints.</p><p>Deletion of a target list recursively deletes each target, from left to right.<strong> </strong>Deletion of a name removes the binding of that name from the local or global namespace, depending on whether the name occurs in a global statement in the same code block. If the nane is unbound, a NameError exception will be raised.</p><p>Deletion of attribute references, subscriptions and slicing’s is passed to the primary object involved; deletion of a slicing is in general equivalent to assignment of an empty slice of the right type (but even this is determined by the sliced object).</p><p>Kindly note that there is no mention of freeing memory. What happens is that you tell Python that it can do whatever it wants with that memory. In this case your Python implementation stores the memory for later use in a memory cache. This allows Python to run faster by not needing to allocate as much memory later.</p><p><strong>Interning</strong></p><p>Interning is the process by which objects are reused on-demand by the memory manager. As startup, the Cpython interpreter, pre-loads a global list of integers in the range [-5, 256]. So anytime a variable references a number within that range, the interpreter will use a cached version of that integer object in memory.</p><p>This is why:</p><p><em>&gt;&gt;&gt; hex(id(a)) == hex(id(b)) → True</em></p><p>where a and b are both referencing a number which falls within the preloaded range of integers and</p><p><em>&gt;&gt;&gt; hex(id(a)) == hex(id(b)) → False</em></p><p>When a and b are both referencing a number which falls outside of the preloaded range of integers. The Python memory manager not only interns integers, it also interns strings that look like variables i.e. short strings like ‘Hello’ and long strings that have no spaces in-between each word that make up the string e.g. “Hello_world_program”.</p><p>You can manually intern a long string if it does not have the normal characteristics of a string that the memory manager would normally intern. You can do this by:</p><p><em>&gt;&gt;&gt; import sys</em></p><p><em>&gt;&gt;&gt; sys.intern(“this is a pretty long string that has spaces, which the memory manager would normally not intern”)</em></p><p>What is the use of interning you might ask? Well, in normal day to day programming, you would hardly ever be required to go that low but if you are building for example, a tokenizer or some program that would be working with a large number of strings, then interning would greatly speed up your code.</p><p><strong>The Python Global Interpreter Lock (GIL)</strong></p><p>The python GIL is a lock that allows only one thread to control the Python interpreter at any given time i.e. only one thread can be executed at once. What exactly does this do you might ask? Well lets return to our explanation of how reference counting in Python is executed; reference count of an object is incremented when:</p><p>1. It is assigned to a variable</p><p>2. Passed as an argument during a function invocation</p><p>3. Passed as an object in an iterable i.e. a list.</p><p>The reference count of an object is also decremented when it is:</p><p>1. Explicitly deleted with the del statement</p><p>2. The variable is assigned another memory location</p><p>3. The variable goes out of scope i.e. after the function has finished running.</p><p>Now imagine if the Python GIL did not exist? That would mean more than one thread can be executed in a Python program that means there might be cases where two or more threads might want to increment or decrement the reference count of an object simultaneously which if it happens would lead to either memory leaks due to memory that never gets released or where the memory is released even when the reference count is not zero i.e. a variable still references it. This phenomenon is called a <strong>Race Condition </strong>and invariables leads to unexpected behavior in code i.e. bugs.</p><p>So the reference count can be kept safe by adding <strong><em>locks </em></strong>to all data structures that are shared across threads so that they are not modified inconsistently. However, adding a lock to each object or groups of objects means multiple locks will exist which can cause another problem — <strong><em>Deadlocks. </em></strong>And deadlocks can only happen if there is more than one lock on an object). Also, another side effect would be decreased performance caused by the repeated acquisition and release of locks.</p><p>The GIL is a single lock on the interpreter itself which adds a rule that execution of any Python bytecode requires acquiring the interpreter lock. This prevents deadlocks (as there is only one lock) and does not introduce much performance overhead. The only disadvantage is that it makes CPU-bound programs single threaded.</p><p>In the end we have been able to see how Python manages memory and object creation with the garbage collector, reference counting and the GIL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc09f7ab00ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Python, Run!!!]]></title>
            <link>https://medium.com/@pystar/run-python-run-3f64d83a50f?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f64d83a50f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[functools]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lru-cache]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Fri, 15 Feb 2019 20:27:53 GMT</pubDate>
            <atom:updated>2019-02-16T05:53:14.373Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you want a speed increase of up to 20% in your code?</p><p>Speed up your python programs with a powerful, yet convenient caching decorator?</p><p>Do you know you can achieve this easily with just a single line of code?</p><p><strong>***</strong>drumroll***</p><p><strong>Introducing lru_cache().</strong></p><p>lru_cache is a function decorator imported from the standard library functools module. It’s Pythons easy to use take on memoization.</p><p><strong>How it works:</strong> It wraps itself around constantly called functions, caching the result of the function invocation thereby providing a speed boost.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/017a5d492fdd6f97c815a814fa8435e7/href">https://medium.com/media/017a5d492fdd6f97c815a814fa8435e7/href</a></iframe><p>Simplistically, the lru_cache consists of a cache dictionary and a linked list.</p><p>The cache dictionary keeps track of the function return values and the linked list keeps track of the function call history.</p><p>Using the timeit module, I noticed up to 20% increase in speed for certain benchmarks. This is due to the good work of developers who rewrote the functools.lru_cache() decorator in C for Python 3.5.</p><p>The lru_cache decorator is so simple and easy to use like all things Python.<br>I advise you use it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f64d83a50f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Database backed Python webapp with Responder, Asyncpg and Postgresql]]></title>
            <link>https://medium.com/@pystar/building-a-database-backed-python-webapp-with-responder-asyncpg-and-postgresql-1a5f3f6c6728?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a5f3f6c6728</guid>
            <category><![CDATA[asyncpg]]></category>
            <category><![CDATA[responder]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[asyncio]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Sat, 03 Nov 2018 21:39:24 GMT</pubDate>
            <atom:updated>2018-11-03T21:39:24.572Z</atom:updated>
            <content:encoded><![CDATA[<pre>import responder</pre><pre>app = responder.API()</pre><pre>@app.route(&quot;/&quot;)<br>async def index(request, response):<br>    response.text = &quot;Hello world&quot;<br>    return</pre><pre>if __name__ == &quot;__main__&quot;:<br>    app.run()</pre><p>The code snippet above displays the ubiquitous “Hello World” message for getting started with any programming framework/language. It doesnt do much more than that, so to get really serious and store user generated content we have to have a data store. We will be working with Asyncpg, Postgresql and Responder.</p><ol><li>Install Pipenv</li></ol><pre>pip install pipenv</pre><p>2. Create a Pipenv virtual environment and activate it.</p><pre>pipenv --python 3.7</pre><pre>pipenv shell</pre><p>3. Install Responder Asyncio and Asyncpg. (We have already assumed Postgresql already exists.</p><pre>pipenv install responder</pre><pre>pipenv install asyncpg</pre><pre>pipenv install asyncio</pre><p>Example: The script below inserts a string (“The badlands story”) into our postgresql database “responder_db” when there is a visit to the index page of the web application.</p><pre>import responder<br>import asyncpg<br>import asyncio</pre><pre>app = responder.Responder()</pre><pre>async def db():<br>    conn = await asyncpg.connect(host=&quot;localhost&quot;, port=5432,         user=[username], password=[password], database=[database]) #This is the connection string to the postgresql database<br>    <br>    await conn.execute(&quot;&quot;&quot;<br>            INSERT INTO responder_db (name) VALUES (&#39;The badlands story&#39;)<br>        &quot;&quot;&quot;)<br>    await conn.close()<br>    response.text = &quot;New Data inserted!&quot;</pre><pre>@app.route(&quot;/&quot;)<br>async def index(request, response):<br>    await db()<br>    response.text = &quot;Hello world!&quot;<br>    return</pre><pre>if __name__ == &quot;__main__&quot;:<br>    app.run()</pre><p>According to recommendations for effective use of asyncpg, for server applications that handle frequent requests and need the database connection for a short period time while handling a request, the use of a connection pool is recommended.</p><p>This will be explored in the next part.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a5f3f6c6728" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zero to Pro: The Only 12 Docker Commands You Need to Know]]></title>
            <link>https://medium.com/@pystar/zero-to-pro-the-only-12-docker-commands-you-need-to-know-5d133a20649f?source=rss-1cf1672f98a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d133a20649f</guid>
            <category><![CDATA[devops-practice]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Pystar]]></dc:creator>
            <pubDate>Sun, 23 Sep 2018 19:39:05 GMT</pubDate>
            <atom:updated>2018-09-25T18:01:20.966Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>What is Docker?</strong></h3><p><strong>Docker</strong> is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud.<a href="https://www.docker.com/why-docker"> <strong>Read more</strong></a></p><p>To create a Docker container you have to:</p><ol><li>Define a Dockerfile and run it -&gt; generates a Docker image</li><li>Run the Dockerfile image-&gt; generates a Docker container.</li></ol><p>Let me show you a sample Docker file and then we can run through each line in it, explaining as we proceed.</p><pre>FROM linuxmintd/mint19-amd64:latest                  (1)</pre><pre>MAINTAINER Ehigie (Pystar) Aito                       (2)  </pre><pre>RUN apt-get update -y                                   (3)</pre><pre>RUN apt-get install -y python-pip python-dev build-essential python3-setuptools</pre><pre>RUN  pip install virtualenv</pre><pre>RUN pip install flask</pre><pre>WORKDIR /root/web                                         (4)</pre><pre>COPY requirements.txt requirements.txt                    (5)  </pre><pre>COPY app.py app.py</pre><pre>EXPOSE 5000                                                (6)</pre><pre>ENTRYPOINT [&quot;python&quot;]                                      (7)</pre><pre>CMD [&quot;app.py&quot;]                                              (8)</pre><pre>ENV FLASK_APP app.py                                        (9)</pre><pre>USER webapp                                                 (10)</pre><pre>VOLUME /webapp/data                                         (11)</pre><pre>ADD <a href="https://www.python.org/ftp/python/3.7.0/Python-3.7.0rc1.tgz">https://www.python.org/ftp/python/3.7.0/Python-3.7.0rc1.tgz</a> . (12)</pre><p>(1) <strong>FROM</strong>: When you create a Docker image, to make it easier you can download and build already existing images. In this example, I am building on (linuxmintd/mint19-amd64:latest) and extending it with my own commands. To search for existing images you can build on from hub.docker.com, run this command:</p><pre>docker search [image name] example linuxmint/debian/Centos</pre><p>(2) <strong>MAINTAINER: </strong>When you create a Dockerfile, you can put in your name in the Dockerfile so users can know the creator. I call this vanity metrics.</p><pre>MAINTAINER Ehigie (Pystar) Aito</pre><p>(3) <strong>RUN: </strong>This command is used when defining a Dockerfile, it run commands instantly during the Dockerfile definition, example usage includes installing dependencies and libraries inside the Docker that are required by subsequent commands in the Dockerfile</p><pre>RUN apt-get update -y</pre><pre>or </pre><pre>RUN apt-get install python-pip -y</pre><p>(4) <strong>WORKDIR</strong>: Here you define the default directory where your commands run within the Docker container.</p><pre>WORKDIR [/PATH/TO/WORKING/DIRECTORY]</pre><p>(5) <strong>COPY: </strong>This command is used to copy files from the local development machine into the Docker container. It works the same way as copying a file from one location to another on your operating system.</p><pre>COPY [SOURCE] [DESTINATION]</pre><pre>COPY requirements.txt requirements.txt</pre><p>(6) <strong>EXPOSE: </strong>You use this command to expose ports in the Docker container and is used to facilitate inter container communication i.e. if you want containers to talk to each other.</p><pre>EXPOSE [PORT]</pre><pre>EXPOSE [5000]          -&gt; This is the default port Flask runs on.</pre><p>(7) <strong>ENTRYPOINT: </strong>This is used to define the default application that is used to run any arguments passed to CMD when Docker container starts.</p><pre>ENTRYPOINT &quot;python&quot;</pre><p>(8) <strong>CMD: </strong>This is used to define commands that are only run when the Docker container is run not when the Dockerfile is defined. CMD and RUN are quite similar but are quite different because of when they are executed.</p><pre>CMD [command]</pre><pre>CMD [app.py]</pre><pre>app.py is run by the default by the program you defined in the ENTRYPOINT switch. So python runs app.py</pre><p>(9) <strong>ENV: </strong>This is used to define environmental variables within the Docker container. It follows this format:</p><pre>ENV [key] [value]</pre><pre>ENV FLASK_APP app.py</pre><p>(10) <strong>USER: </strong>By default, commands in a Docker container are run with the ROOT account. While this isnt encouraged, you can define a new user with the USER command.</p><pre>USER [user_name]</pre><pre>USER webapp</pre><p>(11) <strong>VOLUME: </strong>Whatever data you create when you run a Docker container is ephemeral with a lifetime that only lasts as long as your Docker is running. To store your data you define a directory on your local file system where the container keeps generated data.</p><pre>VOLUME [/PATH/TO/STORAGE/DIRECTORY]</pre><pre>VOLUME /webapp/data</pre><p>(12)<strong> ADD: </strong>This command is similar to <strong>COPY. </strong>It can copy files like the <strong>COPY </strong>command and also download items from URLs to a location in your container. It can also extract compressed data stored in known compression formats.</p><p>After defining your Dockerfile, you build it by running this command:</p><pre>docker build -t [dockercontainer_name] .</pre><pre>Replace the dockercontainer_name with any name of your choosing and dont forget to put the . at the end of the command. It specifies that the container should be built in the current working directory.</pre><p>You can now run the generated Docker container by running this command:</p><pre>docker run -d -p 5000:5000 [dockercontainer_name]</pre><p>Docker is a cool technology and is indispensable for DevOps tasks. Hope this helps wetting your feet in it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d133a20649f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>