Deploy to GitHub pages

This commit is contained in:
github-actions[bot] 2025-09-23 06:50:35 +00:00 committed by GitHub
commit 2e463fba8d
78 changed files with 26089 additions and 0 deletions

0
.nojekyll Normal file
View File

276
404.html Normal file
View File

@ -0,0 +1,276 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Not Found | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Not Found | Portable Python 3.x Interpreter in Modern C">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/404.html">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/404.html">
<meta property="og:title" content="Not Found | Portable Python 3.x Interpreter in Modern C">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/404.html">
<meta property="twitter:title" content="Not Found | Portable Python 3.x Interpreter in Modern C">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="/static/logo.png" rel="icon">
<link href="/resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="/resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="/resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="/resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="/" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="/static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="/static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="max-w-lg mx-auto mt-20 text-center px-6 sm:px-16 md:px-8">
<div class="px-8 md:p-0 text-gray-300 dark:text-dark-650">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto mb-6" style="max-width: 313px" fill="currentColor" viewBox="0 0 313 164"><path d="M156.17 0c-22.28 0-48.83 10.93-48.83 63.03 0 52.36 26.55 63.35 48.83 63.35 22.28 0 48.83-10.99 48.83-63.35C205 10.93 178.45 0 156.17 0zm0 118.38c-27.47 0-40.83-18.1-40.83-55.35C115.35 26 128.7 8 156.17 8 183.65 8 197 26 197 63.03c0 37.24-13.35 55.35-40.83 55.35z"/><path d="M156.17 25.53c-22.03 0-22.03 24.4-22.03 37.5 0 13.22 0 37.82 22.03 37.82s22.03-24.6 22.03-37.82c0-13.11 0-37.5-22.03-37.5zm0 67.32c-10.49 0-14.03-7.53-14.03-29.82 0-21.78 3.67-29.5 14.03-29.5s14.03 7.72 14.03 29.5c0 22.3-3.54 29.82-14.03 29.82zM58.05 37.48a5.95 5.95 0 00-6.73 2.44l-20.51 31a5.986 5.986 0 00-.28 6.15 5.992 5.992 0 005.29 3.16h20.5c3.31 0 6-2.69 6-6v-31a5.95 5.95 0 00-4.27-5.75zm-3.72 34.75H39.54l14.78-22.35v22.35z"/><path d="M93.95 72.23h-6.8v-63c0-3.31-2.69-6-6-6H54.37c-1.96 0-3.8.96-4.92 2.56L1.08 74.98A5.946 5.946 0 000 78.42v18.91c0 3.31 2.69 6 6 6h46.45v14.29c0 3.31 2.69 6 6 6h22.69c3.31 0 6-2.69 6-6v-14.29h6.8c3.31 0 6-2.69 6-6v-19.1c.01-3.31-2.68-6-5.99-6zm-2 23.1h-6.8c-3.31 0-6 2.69-6 6v14.29h-18.7v-14.29c0-3.31-2.69-6-6-6H8V79.05l47.41-67.82h23.73v63c0 3.31 2.69 6 6 6h6.8v15.1zM306.95 72.23h-6.8v-63c0-3.31-2.69-6-6-6h-26.77c-1.96 0-3.8.96-4.92 2.56l-48.37 69.19a5.946 5.946 0 00-1.08 3.44v18.91c0 3.31 2.69 6 6 6h46.45v14.29c0 3.31 2.69 6 6 6h22.69c3.31 0 6-2.69 6-6v-14.29h6.8c3.31 0 6-2.69 6-6v-19.1c0-3.31-2.69-6-6-6zm-2 23.1h-6.8c-3.31 0-6 2.69-6 6v14.29h-18.69v-14.29c0-3.31-2.69-6-6-6H221V79.05l47.41-67.82h23.73v63c0 3.31 2.69 6 6 6h6.8v15.1z"/><path d="M271.05 37.48a5.95 5.95 0 00-6.73 2.44l-20.51 31a5.986 5.986 0 00-.28 6.15 5.992 5.992 0 005.29 3.16h20.5c3.31 0 6-2.69 6-6v-31a5.95 5.95 0 00-4.27-5.75zm-3.72 34.75h-14.78l14.78-22.35v22.35z"/><g><ellipse cx="158.97" cy="158.2" rx="36.9" ry="5.95"/></g></svg>
</div>
<h1 class="mb-6 text-2xl font-bold leading-tight text-gray-900 dark:text-white md:text-4xl">Oops! The page youre looking for doesnt exist.</h1>
<p class="mb-10 text-gray-600 dark:text-dark-350 md:text-lg md:px-4">You may have mistyped the address or the page may have been moved.</p>
<a href="/" class="inline-flex items-center justify-center h-12 px-4 text-sm leading-none text-button-primary-text bg-button-primary rounded shadow-xl focus:outline-none hover:bg-button-primary-hover transition-all duration-100 ease-linear">Go to homepage</a>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = null</script>
</body>
</html>

1
CNAME Normal file
View File

@ -0,0 +1 @@
pocketpy.dev

681
bindings-cpp/index.html Normal file
View File

@ -0,0 +1,681 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Write C++ Bindings | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Write C++ Bindings | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="pkpy provides a pybind11 compatible layer which allows users to do convenient bindings.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/bindings-cpp/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/bindings-cpp/">
<meta property="og:title" content="Write C++ Bindings | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="pkpy provides a pybind11 compatible layer which allows users to do convenient bindings.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/bindings-cpp/">
<meta property="twitter:title" content="Write C++ Bindings | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="pkpy provides a pybind11 compatible layer which allows users to do convenient bindings.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../static/logo.png" rel="icon">
<link href="../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="write-c-bindings" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#write-c-bindings">#</doc-anchor-trigger>
<span>Write C++ Bindings</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="quick-start">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#quick-start">#</doc-anchor-trigger>
<span>Quick Start</span>
</h2>
</doc-anchor-target>
<p>pkpy provides a <a href="https://pybind11.readthedocs.io/en/stable/">pybind11</a> compatible layer which allows users to do convenient bindings.</p>
<p>To begin with, use <code v-pre>py::scoped_interpreter guard{}</code> to start the interpreter before using any Python objects.
Or explicitly call <code v-pre>py::interpreter::initialize()</code> and <code v-pre>py::interpreter::finalize()</code>.</p>
<doc-anchor-target id="module">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#module">#</doc-anchor-trigger>
<span>module</span>
</h3>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cpp"><code v-pre class="language-cpp">#include &lt;pybind11/pybind11.h&gt;
namespace py = pybind11;
PYBIND11_EMBEDDED_MODULE(example, m) {
m.def(&quot;add&quot;, [](int a, int b) {
return a + b;
});
auto math = m.def_submodule(&quot;math&quot;);
}</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="function">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#function">#</doc-anchor-trigger>
<span>function</span>
</h3>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cpp"><code v-pre class="language-cpp">int add(int a, int b) { return a + b; }
int add(int a, int b, int c) { return a + b + c; }
void register_function(py::module_&amp; m)
{
m.def(&quot;add&quot;, py::overload_cast&lt;int, int&gt;(&amp;add));
// support function overload
m.def(&quot;add&quot;, py::overload_cast&lt;int, int, int&gt;(&amp;add));
// bind with default arguments
m.def(&quot;sub&quot;, [](int a, int b) {
return a - b;
}, py::arg(&quot;a&quot;) = 1, py::arg(&quot;b&quot;) = 2);
// bind *args
m.def(&quot;add&quot;, [](py::args args) {
int sum = 0;
for (auto&amp; arg : args) {
sum += arg.cast&lt;int&gt;();
}
return sum;
});
// bind **kwargs
m.def(&quot;add&quot;, [](py::kwargs kwargs) {
int sum = 0;
for (auto item : kwargs) {
sum += item.second.cast&lt;int&gt;();
}
return sum;
});
}</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="class">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#class">#</doc-anchor-trigger>
<span>class</span>
</h3>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cpp"><code v-pre class="language-cpp">struct Point
{
const int x;
int y;
public:
Point() : x(0), y(0) {}
Point(int x, int y) : x(x), y(y) {}
Point(const Point&amp; p) : x(p.x), y(p.y) {}
std::string stringfy() const {
return &quot;(&quot; + std::to_string(x) + &quot;, &quot; + std::to_string(y) + &quot;)&quot;;
}
};
struct Point3D : Point
{
private:
int z;
public:
Point3D(int x, int y, int z) : Point(x, y), z(z) {}
int get_z() const { return z; }
void set_z(int z) { this-&gt;z = z; }
};
void bind_class(py::module_&amp; m)
{
py::class_&lt;Point&gt;(m, &quot;Point&quot;)
.def(py::init&lt;&gt;())
.def(py::init&lt;int, int&gt;())
.def(py::init&lt;const Point&amp;&gt;())
.def_readonly(&quot;x&quot;, &amp;Point::x)
.def_readwrite(&quot;y&quot;, &amp;Point::y)
.def(&quot;__str__&quot;, &amp;Point::stringfy);
// only support single inheritance
py::class_&lt;Point3D, Point&gt;(m, &quot;Point3D&quot;, py::dynamic_attr())
.def(py::init&lt;int, int, int&gt;())
.def_property(&quot;z&quot;, &amp;Point3D::get_z, &amp;Point3D::set_z);
// dynamic_attr will enable the dict of bound class
}</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="operators">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#operators">#</doc-anchor-trigger>
<span>operators</span>
</h3>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cpp"><code v-pre class="language-cpp">#include &lt;pybind11/operators.h&gt;
namespace py = pybind11;
struct Int {
int value;
Int(int value) : value(value) {}
Int operator+(const Int&amp; other) const {
return Int(value + other.value);
}
Int operator-(const Int&amp; other) const {
return Int(value - other.value);
}
bool operator==(const Int&amp; other) const {
return value == other.value;
}
bool operator!=(const Int&amp; other) const {
return value != other.value;
}
};
void bind_operators(py::module_&amp; m)
{
py::class_&lt;Int&gt;(m, &quot;Int&quot;)
.def(py::init&lt;int&gt;())
.def(py::self + py::self)
.def(py::self - py::self)
.def(py::self == py::self)
.def(py::self != py::self);
// other operators are similar
}</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="pyobject">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#pyobject">#</doc-anchor-trigger>
<span>py::object</span>
</h3>
</doc-anchor-target>
<p><code v-pre>py::object</code> is just simple wrapper around <code v-pre>PyVar</code>. It supports some convenient methods to interact with Python objects.</p>
<p>here are some common methods:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cpp"><code v-pre class="language-cpp">obj.attr(&quot;x&quot;); // access attribute
obj[1]; // access item
obj.is_none(); // same as obj is None in Python
obj.is(obj2); // same as obj is obj2 in Python
// operators
obj + obj2; // same as obj + obj2 in Python
// ...
obj == obj2; // same as obj == obj2 in Python
// ...
obj(...); // same as obj.__call__(...)
py::cast(obj); // cast to Python object
obj.cast&lt;T&gt;; // cast to C++ type
py::type::of(obj); // get type of obj
py::type::of&lt;T&gt;(); // get type of T, if T is registered</code></pre>
</doc-codeblock></div>
<p>you can also create some builtin objects with their according wrappers:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cpp"><code v-pre class="language-cpp">py::bool_ b = {true};
py::int_ i = {1};
py::float_ f = {1.0};
py::str s = {&quot;hello&quot;};
py::list l = {1, 2, 3};
py::tuple t = {1, 2, 3};
// ...</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="more-examples">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#more-examples">#</doc-anchor-trigger>
<span>More Examples</span>
</h2>
</doc-anchor-target>
<p>More examples please see the test <a href="https://github.com/pocketpy/gsoc-2024-dev/tree/main/pybind11/tests">folder</a> in the GSoC repository. All tested features are supported.</p>
<doc-anchor-target id="limits-and-comparison">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#limits-and-comparison">#</doc-anchor-trigger>
<span>Limits and Comparison</span>
</h2>
</doc-anchor-target>
<p>This is a feature list of pybind11 for pocketpy. It lists all completed and pending features. It also lists the features that cannot be implemented in the current version of pocketpy.</p>
<doc-anchor-target id="function-1">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#function-1">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/advanced/functions.html">Function</a></span>
</h3>
</doc-anchor-target>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Function overloading</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Return value policy</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> is_prepend</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>*args</code> and <code v-pre>**kwargs</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Keep-alive</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Call Guard</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Default arguments</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Keyword-Only arguments</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Positional-Only arguments</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Allow/Prohibiting None arguments</li>
</ul>
<doc-anchor-target id="class-1">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#class-1">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/classes.html">Class</a></span>
</h3>
</doc-anchor-target>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Creating bindings for a custom type</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Binding lambda functions</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Dynamic attributes</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Inheritance and automatic downcasting</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Enumerations and internal types</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Instance and static fields</li>
</ul>
<blockquote>
<p>Binding static fields may never be implemented in pocketpy because it requires a metaclass, which is a heavy and infrequently used feature.</p>
</blockquote>
<doc-anchor-target id="exceptions">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#exceptions">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/advanced/exceptions.html">Exceptions</a></span>
</h3>
</doc-anchor-target>
<p>Need further discussion.</p>
<doc-anchor-target id="smart-pointers">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#smart-pointers">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/advanced/smart_ptrs.html">Smart pointers</a></span>
</h3>
</doc-anchor-target>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> std::shared_ptr</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> std::unique_ptr</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Custom smart pointers</li>
</ul>
<doc-anchor-target id="type-conversions">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#type-conversions">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/advanced/cast/index.html">Type conversions</a></span>
</h3>
</doc-anchor-target>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Python built-in types</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> STL Containers</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Functional</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Chrono</li>
</ul>
<doc-anchor-target id="python-c-interface">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#python-c-interface">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/advanced/pycpp/object.html">Python C++ interface</a></span>
</h3>
</doc-anchor-target>
<p>Need further discussion.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>object</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>none</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>type</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>bool_</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>int_</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>float_</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>str</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>bytes</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>bytearray</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>tuple</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>list</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>set</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>dict</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>slice</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>iterable</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>iterator</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>function</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>buffer</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>memoryview</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>capsule</code></li>
</ul>
<doc-anchor-target id="miscellaneous">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#miscellaneous">#</doc-anchor-trigger>
<span><a href="https://pybind11.readthedocs.io/en/stable/advanced/misc.html">Miscellaneous</a></span>
</h3>
</doc-anchor-target>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Global Interpreter Lock (GIL)</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> Binding sequence data types, iterators, the slicing protocol, etc.</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> Convenient operators binding</li>
</ul>
<doc-anchor-target id="differences-between-cpython-and-pocketpy">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#differences-between-cpython-and-pocketpy">#</doc-anchor-trigger>
<span>Differences between CPython and pocketpy</span>
</h3>
</doc-anchor-target>
<ul>
<li><p>only <code v-pre>add</code>, <code v-pre>sub</code> and <code v-pre>mul</code> have corresponding right versions in pocketpy. So if you bind <code v-pre>int() &gt;&gt; py::self</code>, it will has no effect in pocketpy.</p>
</li>
<li><p><code v-pre>__new__</code> and <code v-pre>__del__</code> are not supported in pocketpy.</p>
</li>
<li><p>in-place operators, such as <code v-pre>+=</code>, <code v-pre>-=</code>, <code v-pre>*=</code>, etc., are not supported in pocketpy.</p>
</li>
<li><p>the return value of <code v-pre>globals</code> is immutable in pocketpy.</p>
</li>
</ul>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../bindings/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Write C Bindings</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../features/basic/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Basic Features</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Write C++ Bindings", level: 1, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

402
bindings/index.html Normal file
View File

@ -0,0 +1,402 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Write C Bindings | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Write C Bindings | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="In order to use a C/C++ library in python, you need to write bindings for it.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/bindings/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/bindings/">
<meta property="og:title" content="Write C Bindings | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="In order to use a C/C++ library in python, you need to write bindings for it.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/bindings/">
<meta property="twitter:title" content="Write C Bindings | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="In order to use a C/C++ library in python, you need to write bindings for it.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../static/logo.png" rel="icon">
<link href="../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="write-c-bindings" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#write-c-bindings">#</doc-anchor-trigger>
<span>Write C Bindings</span>
</h1>
</doc-anchor-target>
<p>In order to use a C/C++ library in python, you need to write bindings for it.</p>
<p>pkpy uses an universal signature to wrap a C function pointer as a python function or method, i.e <code v-pre>py_CFunction</code>.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">typedef bool (*py_CFunction)(int argc, py_Ref argv);</code></pre>
</doc-codeblock></div>
<ul>
<li><code v-pre>argc</code> is the number of arguments passed to the function.</li>
<li><code v-pre>argv</code> is the pointer to the first argument.</li>
</ul>
<p>If successful, the function should return <code v-pre>true</code> and set the return value in <code v-pre>py_retval()</code>. In case there is no return value, you should use <code v-pre>py_newnone(py_retval())</code>.
If an error occurs, the function should raise an exception and return <code v-pre>false</code>.</p>
<doc-anchor-target id="steps">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#steps">#</doc-anchor-trigger>
<span>Steps</span>
</h2>
</doc-anchor-target>
<p>Say you have a function <code v-pre>add</code> that takes two integers and returns their sum.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">int add(int a, int b) {
return a + b;
}</code></pre>
</doc-codeblock></div>
<p>Here is how you can write the binding for it:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">// 1. Define a wrapper function with the signature `py_CFunction`.
bool py_add(int argc, py_Ref argv) {
// 2. Check the number of arguments.
PY_CHECK_ARGC(2);
// 3. Check the type of arguments.
PY_CHECK_ARG_TYPE(0, tp_int);
PY_CHECK_ARG_TYPE(1, tp_int);
// 4. Convert the arguments into C types.
int _0 = py_toint(py_arg(0));
int _1 = py_toint(py_arg(1));
// 5. Call the original function.
int res = add(_0, _1);
// 6. Set the return value.
py_newint(py_retval(), res);
// 7. Return `true`.
return true;
}</code></pre>
</doc-codeblock></div>
<p>Once you have the wrapper function, you can bind it to a python module via <code v-pre>py_bindfunc</code>.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">py_GlobalRef mod = py_getmodule(&quot;__main__&quot;);
py_bindfunc(mod, &quot;add&quot;, py_add);</code></pre>
</doc-codeblock></div>
<p>Alternatively, you can use <code v-pre>py_bind</code> with a signature, which allows you to specify some default values.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">py_GlobalRef mod = py_getmodule(&quot;__main__&quot;);
py_bind(mod, &quot;add(a, b=1)&quot;, py_add);</code></pre>
</doc-codeblock></div>
<p>See also:</p>
<ul>
<li><a href="../c-api/functions/#py_bind"><code v-pre>py_bind</code></a></li>
<li><a href="../c-api/functions/#py_bindmethod"><code v-pre>py_bindmethod</code></a></li>
<li><a href="../c-api/functions/#py_bindfunc"><code v-pre>py_bindfunc</code></a></li>
<li><a href="../c-api/functions/#py_bindproperty"><code v-pre>py_bindproperty</code></a></li>
<li><a href="../c-api/functions/#py_newmodule"><code v-pre>py_newmodule</code></a></li>
<li><a href="../c-api/functions/#py_newtype"><code v-pre>py_newtype</code></a></li>
</ul>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../quick-start/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Quick Start</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../bindings-cpp/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Write C++ Bindings</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Write C Bindings", level: 1, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

2991
c-api/functions/index.html Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,437 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Introduction | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Introduction | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="All public functions in the C API are prefixed with py_ in pocketpy.h.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/c-api/introduction/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/c-api/introduction/">
<meta property="og:title" content="Introduction | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="All public functions in the C API are prefixed with py_ in pocketpy.h.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/c-api/introduction/">
<meta property="twitter:title" content="Introduction | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="All public functions in the C API are prefixed with py_ in pocketpy.h.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="introduction" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#introduction">#</doc-anchor-trigger>
<span>Introduction</span>
</h1>
</doc-anchor-target>
<p>All public functions in the C API are prefixed with <code v-pre>py_</code> in <a href="https://github.com/pocketpy/pocketpy/blob/main/include/pocketpy/pocketpy.h">pocketpy.h</a>.</p>
<doc-anchor-target id="overview">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#overview">#</doc-anchor-trigger>
<span>Overview</span>
</h2>
</doc-anchor-target>
<p>pocketpy works with opaque references. <code v-pre>py_Ref</code> is used to reference objects in the virtual machine. It is your responsibility to ensure a reference is valid before using it. See following reference types:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">/// A generic reference to a python object.
typedef py_TValue* py_Ref;
/// A reference which has the same lifespan as the python object.
typedef py_TValue* py_ObjectRef;
/// A global reference which has the same lifespan as the VM.
typedef py_TValue* py_GlobalRef;
/// A specific location in the value stack of the VM.
typedef py_TValue* py_StackRef;
/// An item reference to a container object. It invalidates when the container is modified.
typedef py_TValue* py_ItemRef;
/// An output reference for returning a value.
typedef py_TValue* py_OutRef;</code></pre>
</doc-codeblock></div>
<p>You can store python objects into &quot;stack&quot; or &quot;register&quot;.
We provide 8 registers and you can get references to them by <code v-pre>py_reg()</code>.
Also, <code v-pre>py_retval()</code> is a special register that is used to store the return value of a <code v-pre>py_CFunction</code>.
Registers are shared so they could be overwritten easily.
If you want to store python objects across function calls, you should store them into the stack via <code v-pre>py_push()</code> and <code v-pre>py_pop()</code>.</p>
<doc-anchor-target id="data-types">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#data-types">#</doc-anchor-trigger>
<span>Data Types</span>
</h2>
</doc-anchor-target>
<p>You can do conversions between C types and python objects using the following functions:</p>
<div class="table-wrapper scrollbar overflow-hidden">
<table class="comfortable">
<thead>
<tr>
<th>C type</th>
<th>Python type</th>
<th>C to Python</th>
<th>Python to C</th>
</tr>
</thead>
<tbody>
<tr>
<td>char,short,int,long</td>
<td>int</td>
<td><code v-pre>py_newint()</code></td>
<td><code v-pre>py_toint()</code></td>
</tr>
<tr>
<td>float,double</td>
<td>float</td>
<td><code v-pre>py_newfloat()</code></td>
<td><code v-pre>py_tofloat()</code>, <code v-pre>py_castfloat()</code></td>
</tr>
<tr>
<td>bool</td>
<td>bool</td>
<td><code v-pre>py_newbool()</code></td>
<td><code v-pre>py_tobool()</code></td>
</tr>
<tr>
<td>const char*</td>
<td>str</td>
<td><code v-pre>py_newstr()</code></td>
<td><code v-pre>py_tostr()</code></td>
</tr>
<tr>
<td>void*,intptr_t</td>
<td>int</td>
<td><code v-pre>py_newint()</code></td>
<td><code v-pre>(void*)py_toint()</code></td>
</tr>
</tbody>
</table>
</div>
<hr>
<doc-anchor-target id="py_raise-macro">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#py_raise-macro">#</doc-anchor-trigger>
<span><code v-pre>PY_RAISE</code> macro</span>
</h3>
</doc-anchor-target>
<p>Mark a function that can raise an exception on failure.</p>
<ul>
<li>If the function returns <code v-pre>bool</code>, then <code v-pre>false</code> means an exception is raised.</li>
<li>If the function returns <code v-pre>int</code>, then <code v-pre>-1</code> means an exception is raised.</li>
</ul>
<doc-anchor-target id="py_return-macro">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#py_return-macro">#</doc-anchor-trigger>
<span><code v-pre>PY_RETURN</code> macro</span>
</h3>
</doc-anchor-target>
<p>Mark a function that can store a value in <code v-pre>py_retval()</code> on success.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/ub/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Undefined Behaviour</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../c-api/functions/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Functions</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Introduction", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,592 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Coding Style Guide | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Coding Style Guide | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Use four spaces for indentation. Do not use TAB.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/coding-style-guide/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/coding-style-guide/">
<meta property="og:title" content="Coding Style Guide | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Use four spaces for indentation. Do not use TAB.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/coding-style-guide/">
<meta property="twitter:title" content="Coding Style Guide | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Use four spaces for indentation. Do not use TAB.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../static/logo.png" rel="icon">
<link href="../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="coding-style-guide" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#coding-style-guide">#</doc-anchor-trigger>
<span>Coding Style Guide</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="indentation">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#indentation">#</doc-anchor-trigger>
<span>Indentation</span>
</h2>
</doc-anchor-target>
<p>Use four spaces for indentation. Do not use <code v-pre>TAB</code>.</p>
<doc-anchor-target id="strings">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#strings">#</doc-anchor-trigger>
<span>Strings</span>
</h2>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Prefer single quotes for strings
s = 'this is a string'
# Use double quotes only if the string itself contains a single quote
s = &quot;this ' is single quote&quot;</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="docstrings">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#docstrings">#</doc-anchor-trigger>
<span>Docstrings</span>
</h2>
</doc-anchor-target>
<p>Always use triple quotes for docstrings.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">def f():
&quot;&quot;&quot;This is a multi-line docstring.
Here is some content. Docstrings partially support Markdown.
&quot;&quot;&quot;
def g():
&quot;&quot;&quot;This is a single-line docstring.&quot;&quot;&quot;</code></pre>
</doc-codeblock></div>
<p>Use natural language to describe the function&#x27;s purpose. Do not enumerate each parameter and return value.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Correct
def add(a: int, b: int):
&quot;&quot;&quot;Add two integers `a` and `b`.&quot;&quot;&quot;
# Incorrect
def add(a: int, b: int):
&quot;&quot;&quot;
@param a, the first argument
@param b, the second argument
@return, the result of a + b
&quot;&quot;&quot;</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="spaces">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#spaces">#</doc-anchor-trigger>
<span>Spaces</span>
</h2>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Add a space after `,` or `:`
a, b = 1, 2
c = [1, 2, 3]
d = {'key': 'value'}
# Spaces may be added around operators
res = 1 + 2
if res &lt; 2: pass
# Spaces can also be selectively added to indicate operator precedence
x = x * 2 - 1
hypot2 = x * x + y * y
c = (a + b) * (a - b)
# Add a space after `:` in type annotations
def f(a: int, b: float): ...
def g() -&gt; int: ...
# Add spaces around `=` when specifying default values in function parameters
def f(a: int = 1, b: int | None = None): ...
# However, omit spaces if the parameter has no type annotation
def f(a=1, b=2): pass
# Do not add spaces in keyword arguments when calling functions
print(1, 2, 3, end='', sep=',')
f(a=10, b=20)</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="naming-conventions">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#naming-conventions">#</doc-anchor-trigger>
<span>Naming Conventions</span>
</h2>
</doc-anchor-target>
<ul>
<li>Classes: <code v-pre>CapitalizedWords</code></li>
<li>Functions and variables: <code v-pre>lower_case_with_underscores</code></li>
<li>Constants and enums: <code v-pre>UPPER_CASE_WITH_UNDERSCORES</code> or <code v-pre>CapitalizedWords</code></li>
<li>Anonymous ordered variables: <code v-pre>_0</code>, <code v-pre>_1</code>, <code v-pre>_2</code></li>
<li>Discarded variables: <code v-pre>_</code></li>
<li>Some standard library functions: <code v-pre>lowercase</code></li>
</ul>
<p>Here are some commonly used naming conventions:</p>
<ul>
<li><code v-pre>self</code>: The first parameter of an instance method</li>
<li><code v-pre>cls</code>: The first parameter of class methods and <code v-pre>__new__</code></li>
</ul>
<doc-anchor-target id="using-abbreviations">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#using-abbreviations">#</doc-anchor-trigger>
<span>Using Abbreviations</span>
</h3>
</doc-anchor-target>
<p>Use abbreviations only for temporary variables and internal implementations.</p>
<p>Abbreviations should be well-established, include key syllables of the original word, and be immediately recognizable.</p>
<ul>
<li><code v-pre>context</code> -&gt; <code v-pre>ctx</code> (✔)</li>
<li><code v-pre>temporary</code> -&gt; <code v-pre>tmp</code> (✔)</li>
<li><code v-pre>distribution</code> -&gt; <code v-pre>dist</code> (✔)</li>
<li><code v-pre>visited</code> -&gt; <code v-pre>vis</code> (<span class="docs-emoji">&#x274C;</span>)</li>
</ul>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Incorrect: Using abbreviations in public function parameters
def some_pub_fn(ctx, req_id, data):
pass
# Correct
def some_public_function(context, request_id, data):
pass</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="using-precise-terminology">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#using-precise-terminology">#</doc-anchor-trigger>
<span>Using Precise Terminology</span>
</h3>
</doc-anchor-target>
<p>Naming should convey precise meanings, especially when multiple synonyms exist.</p>
<p>For example, <code v-pre>count</code>, <code v-pre>size</code>, and <code v-pre>length</code> all relate to quantity, but they have different nuances:</p>
<ul>
<li><code v-pre>count</code>: Represents a counted value</li>
<li><code v-pre>length</code>: Represents the number of elements in a container</li>
<li><code v-pre>size</code>: Represents the byte size of an object</li>
</ul>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">s = 'aaabc⭐'
count = s.count('a')
length = len(s)
size = len(s.encode())
print(f&quot;{s!r} has a length of {length}, a size of {size} bytes, and contains {count} occurrences of 'a'&quot;)
# 'aaabc⭐' has a length of 6, a size of 8 bytes, and contains 3 occurrences of 'a'</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="using-professional-terminology">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#using-professional-terminology">#</doc-anchor-trigger>
<span>Using Professional Terminology</span>
</h3>
</doc-anchor-target>
<ul>
<li>For item quantities in a game: <code v-pre>quantity</code> is better than <code v-pre>item_count</code></li>
<li>For grid counts: <code v-pre>area</code> (meaning surface area) is better than <code v-pre>grid_count</code></li>
</ul>
<doc-anchor-target id="avoiding-built-in-names">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#avoiding-built-in-names">#</doc-anchor-trigger>
<span>Avoiding Built-in Names</span>
</h3>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Incorrect: Overwriting `builtins.map`
map = [[1, 2, 3], [4, 5, 6]]
# Incorrect: Overwriting `builtins.type`
type = some_thing.type</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="internal-functions-and-classes">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#internal-functions-and-classes">#</doc-anchor-trigger>
<span>Internal Functions and Classes</span>
</h3>
</doc-anchor-target>
<p>Use a single underscore <code v-pre>_</code> as a prefix for internal functions. Never use a double underscore <code v-pre>__</code> (except for magic methods).</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">def _internal_func():
&quot;&quot;&quot;This is an internal function.&quot;&quot;&quot;
class _InternalClass:
def _internal_f(self): pass</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="importing-modules">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#importing-modules">#</doc-anchor-trigger>
<span>Importing Modules</span>
</h2>
</doc-anchor-target>
<ol>
<li>Import standard library modules first.</li>
<li>Then import third-party dependencies.</li>
<li>Finally, import project-specific modules.</li>
</ol>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from typing import Any
from collections import deque
from array2d import array2d
from ..utils import logger</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="coding-practices">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#coding-practices">#</doc-anchor-trigger>
<span>Coding Practices</span>
</h2>
</doc-anchor-target>
<p>Use <code v-pre>is not</code> when checking for <code v-pre>None</code>. Do not explicitly compare with <code v-pre>True</code> or <code v-pre>False</code>.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Correct
if x is not None: pass
# Incorrect
if x != None: pass
# Correct
x = True
if x: pass
if not x: pass
# Incorrect
if x == True: pass
if x is True: pass
if x != False: pass</code></pre>
</doc-codeblock></div>
<p>The <code v-pre>if</code> statement implicitly calls <code v-pre>bool()</code>, so it can be used to check if a container is empty.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">not_empty_list = [1]
not_empty_string = '1'
truth = True
if not_empty_list:
print('true value')
if not_empty_string:
print('true value')
if truth:
print('true value')
# Explicitly checking for emptiness is also valid
if len(not_empty_list) &gt; 0: pass</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="references">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#references">#</doc-anchor-trigger>
<span>References</span>
</h2>
</doc-anchor-target>
<p><a href="https://peps.python.org/pep-0008/">PEP 8 Style Guide for Python Code</a></p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../gsoc2024/ideas/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Project Ideas</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../performance/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Performance</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Coding Style Guide", level: 1, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

545
features/basic/index.html Normal file
View File

@ -0,0 +1,545 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Basic Features | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Basic Features | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="The following table shows the basic features of pkpy with respect to cpython.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/features/basic/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/features/basic/">
<meta property="og:title" content="Basic Features | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="The following table shows the basic features of pkpy with respect to cpython.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/features/basic/">
<meta property="twitter:title" content="Basic Features | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="The following table shows the basic features of pkpy with respect to cpython.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="basic-features" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#basic-features">#</doc-anchor-trigger>
<span>Basic Features</span>
</h1>
</doc-anchor-target>
<p>The following table shows the basic features of pkpy with respect to <a href="https://github.com/python/cpython">cpython</a>.</p>
<div class="table-wrapper scrollbar overflow-hidden">
<table class="comfortable">
<thead>
<tr>
<th>Name</th>
<th>Example</th>
<th>Supported</th>
</tr>
</thead>
<tbody>
<tr>
<td>If Else</td>
<td><code v-pre>if..else..elif</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Loop</td>
<td><code v-pre>for/while/break/continue</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Function</td>
<td><code v-pre>def f(x,*args,y=1):</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Subclass</td>
<td><code v-pre>class A(B):</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>List</td>
<td><code v-pre>[1, 2, 'a']</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>ListComp</td>
<td><code v-pre>[i for i in range(5)]</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Slice</td>
<td><code v-pre>a[1:2], a[:2], a[1:]</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Tuple</td>
<td><code v-pre>(1, 2, 'a')</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Dict</td>
<td><code v-pre>{'a': 1, 'b': 2}</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>F-String</td>
<td><code v-pre>f'value is {x}'</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Unpacking</td>
<td><code v-pre>a, b = 1, 2</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Star Unpacking</td>
<td><code v-pre>a, *b = [1, 2, 3]</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Exception</td>
<td><code v-pre>raise/try..except..</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Dynamic Code</td>
<td><code v-pre>eval()/exec()</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Reflection</td>
<td><code v-pre>hasattr()/getattr()/setattr()</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Import</td>
<td><code v-pre>import/from..import</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Context Block</td>
<td><code v-pre>with &lt;expr&gt; as &lt;id&gt;:</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Type Annotation</td>
<td><code v-pre>def f(a:int, b:float=1)</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Generator</td>
<td><code v-pre>yield i</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Decorator</td>
<td><code v-pre>@cache</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
<tr>
<td>Match Case</td>
<td><code v-pre>match code: case 200:</code></td>
<td><span class="docs-emoji">&#x2705;</span></td>
</tr>
</tbody>
</table>
</div>
<doc-anchor-target id="supported-magic-methods">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#supported-magic-methods">#</doc-anchor-trigger>
<span>Supported magic methods</span>
</h2>
</doc-anchor-target>
<doc-anchor-target id="unary-operators">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#unary-operators">#</doc-anchor-trigger>
<span>Unary operators</span>
</h4>
</doc-anchor-target>
<ul>
<li><code v-pre>__repr__</code></li>
<li><code v-pre>__str__</code></li>
<li><code v-pre>__hash__</code></li>
<li><code v-pre>__len__</code></li>
<li><code v-pre>__iter__</code></li>
<li><code v-pre>__next__</code></li>
<li><code v-pre>__neg__</code></li>
</ul>
<doc-anchor-target id="logical-operators">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#logical-operators">#</doc-anchor-trigger>
<span>Logical operators</span>
</h4>
</doc-anchor-target>
<ul>
<li><code v-pre>__eq__</code></li>
<li><code v-pre>__lt__</code></li>
<li><code v-pre>__le__</code></li>
<li><code v-pre>__gt__</code></li>
<li><code v-pre>__ge__</code></li>
<li><code v-pre>__contains__</code></li>
</ul>
<doc-anchor-target id="binary-operators">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#binary-operators">#</doc-anchor-trigger>
<span>Binary operators</span>
</h4>
</doc-anchor-target>
<ul>
<li><code v-pre>__add__</code></li>
<li><code v-pre>__radd__</code></li>
<li><code v-pre>__sub__</code></li>
<li><code v-pre>__rsub__</code></li>
<li><code v-pre>__mul__</code></li>
<li><code v-pre>__rmul__</code></li>
<li><code v-pre>__truediv__</code></li>
<li><code v-pre>__floordiv__</code></li>
<li><code v-pre>__mod__</code></li>
<li><code v-pre>__pow__</code></li>
<li><code v-pre>__matmul__</code></li>
<li><code v-pre>__lshift__</code></li>
<li><code v-pre>__rshift__</code></li>
<li><code v-pre>__and__</code></li>
<li><code v-pre>__or__</code></li>
<li><code v-pre>__xor__</code></li>
<li><code v-pre>__invert__</code></li>
</ul>
<doc-anchor-target id="indexer">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#indexer">#</doc-anchor-trigger>
<span>Indexer</span>
</h4>
</doc-anchor-target>
<ul>
<li><code v-pre>__getitem__</code></li>
<li><code v-pre>__setitem__</code></li>
<li><code v-pre>__delitem__</code></li>
</ul>
<doc-anchor-target id="specials">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#specials">#</doc-anchor-trigger>
<span>Specials</span>
</h4>
</doc-anchor-target>
<ul>
<li><code v-pre>__new__</code></li>
<li><code v-pre>__init__</code></li>
<li><code v-pre>__call__</code></li>
<li><code v-pre>__divmod__</code></li>
<li><code v-pre>__enter__</code></li>
<li><code v-pre>__exit__</code></li>
<li><code v-pre>__name__</code></li>
<li><code v-pre>__all__</code></li>
</ul>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../bindings-cpp/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Write C++ Bindings</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../features/differences/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Comparison with CPython</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Basic Features", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,465 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Debugging | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Debugging | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="To debug a pocketpy program, you need to install our VSCode extension first:">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/features/debugging/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/features/debugging/">
<meta property="og:title" content="Debugging | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="To debug a pocketpy program, you need to install our VSCode extension first:">
<meta property="og:image" content="https://pocketpy.dev/static/debugger/launch_json.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/features/debugging/">
<meta property="twitter:title" content="Debugging | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="To debug a pocketpy program, you need to install our VSCode extension first:">
<meta property="twitter:image" content="https://pocketpy.dev/static/debugger/launch_json.png">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="debugging" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#debugging">#</doc-anchor-trigger>
<span>Debugging</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="install-vscode-extension">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#install-vscode-extension">#</doc-anchor-trigger>
<span>Install VSCode Extension</span>
</h2>
</doc-anchor-target>
<p>To debug a pocketpy program, you need to install our VSCode extension first:</p>
<p><a href="https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy">https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy</a></p>
<div class="flex mb-6">
<div class="shrink-0 w-1.5 rounded-tl-lg rounded-bl-lg bg-callout-primary"></div>
<div class="flex w-full py-4 border border-l-0 rounded-tr-lg rounded-br-lg doc-callout bg-callout-base-bg border-callout-base-border" role="alert">
<div class="flex items-center ml-4 h-7">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px text-callout-primary" width="22" height="22" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor"><g>
<path d="M12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9z"></path>
<path d="M12 11c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zM12.01 7c-.56 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path>
<path fill="none" d="M0 0h24v24H0z"></path>
</g></g>
</svg>
</div>
<div class="pr-5 ml-3 w-full">
<p>The VSCode extension requires pocketpy version &gt;= <code v-pre>2.1.1</code></p>
</div>
</div>
</div>
<doc-anchor-target id="create-a-launchjson-file">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#create-a-launchjson-file">#</doc-anchor-trigger>
<span>Create a <code v-pre>launch.json</code> file</span>
</h2>
</doc-anchor-target>
<p>Navigate to the Debug view in VSCode, and click on &quot;create a launch.json file&quot; link.
In the dropdown menu, select &quot;pocketpy&quot;.</p>
<p><figure class="content-center">
<img src="../../static/debugger/launch_json.png" alt="launch_json" class="rounded-image-rounded border-image-border border-image-border-width" />
<figcaption class="caption">launch_json</figcaption>
</figure>
</p>
<p>Then a default <code v-pre>launch.json</code> file will be created in the <code v-pre>.vscode</code> folder
with a sample pocketpy debug configuration.</p>
<doc-anchor-target id="how-does-it-work">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#how-does-it-work">#</doc-anchor-trigger>
<span>How does it work?</span>
</h2>
</doc-anchor-target>
<p>pocketpy provides a C-API <code v-pre>py_debugger_waitforattach</code>,
which starts a debug server and waits for the VSCode extension to attach.
When the debugger is attached, the program will continue to run.</p>
<ul>
<li>If you are using pocketpy&#x27;s standalone executable <code v-pre>main.exe</code>, you can pass <code v-pre>--debug</code> flag to it. This will automatically call <code v-pre>py_debugger_waitforattach(&quot;127.0.0.1&quot;, 6110)</code> before running your program.</li>
<li>If you are embedding pocketpy as a library, you need to call <code v-pre>py_debugger_waitforattach</code> manually in your C/C++ code.</li>
</ul>
<doc-anchor-target id="configuration">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#configuration">#</doc-anchor-trigger>
<span>Configuration</span>
</h2>
</doc-anchor-target>
<ul>
<li><code v-pre>type</code>: must be <code v-pre>pocketpy</code></li>
<li><code v-pre>request</code>: can be <code v-pre>attach</code> or <code v-pre>launch</code></li>
<li><code v-pre>name</code>: the name of this configuration</li>
<li><code v-pre>port</code>: the port number of the debug server, must match the one in <code v-pre>py_debugger_waitforattach</code></li>
<li><code v-pre>host</code>: the host of the debug server, must match the one in <code v-pre>py_debugger_waitforattach</code></li>
<li><code v-pre>sourceFolder</code>: the root folder of your python source code, default to <code v-pre>${workspaceFolder}</code>. However,
sometimes you may run your program from a subfolder, in this case you need to set <code v-pre>sourceFolder</code> to the correct path. If this is not set correctly, breakpoints will not be hit.</li>
<li><code v-pre>program</code>: (for launch mode only) the path to the executable file which calls <code v-pre>py_debugger_waitforattach</code>, e.g. the pocketpy standalone executable <code v-pre>main.exe</code>.</li>
<li><code v-pre>args</code>: (for launch mode only) the arguments to pass to the executable file, e.g. <code v-pre>--debug</code> and the script path if you are using <code v-pre>main.exe</code>.</li>
<li><code v-pre>cwd</code>: (for launch mode only) the working directory to launch the executable file, default to <code v-pre>${workspaceFolder}</code>.</li>
</ul>
<doc-anchor-target id="for-attach-mode">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#for-attach-mode">#</doc-anchor-trigger>
<span>For attach mode</span>
</h3>
</doc-anchor-target>
<p>In this mode, you need to start your pocketpy program manually which must call <code v-pre>py_debugger_waitforattach</code> first.
After the program starts, you can let VSCode attach to the debug server.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-json"><code v-pre class="language-json">{
&quot;type&quot;: &quot;pocketpy&quot;,
&quot;request&quot;: &quot;attach&quot;,
&quot;name&quot;: &quot;Attach to pocketpy program&quot;,
&quot;port&quot;: 6110,
&quot;host&quot;: &quot;localhost&quot;,
&quot;sourceFolder&quot;: &quot;${workspaceFolder}&quot;
}</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="for-launch-mode">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#for-launch-mode">#</doc-anchor-trigger>
<span>For launch mode</span>
</h3>
</doc-anchor-target>
<p>In this mode, VSCode will start your program with the specified <code v-pre>program</code>, <code v-pre>args</code> and <code v-pre>cwd</code>.
After the program starts, VSCode attempts to attach to the debug server automatically.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-json"><code v-pre class="language-json">{
&quot;type&quot;: &quot;pocketpy&quot;,
&quot;request&quot;: &quot;launch&quot;,
&quot;name&quot;: &quot;Launch pocketpy program&quot;,
&quot;port&quot;: 6110,
&quot;host&quot;: &quot;localhost&quot;,
&quot;sourceFolder&quot;: &quot;${workspaceFolder}&quot;,
&quot;program&quot;: &quot;${workspaceFolder}/pocketpy/main.exe&quot;,
&quot;args&quot;: [
&quot;--debug&quot;
],
&quot;cwd&quot;: &quot;${workspaceFolder}&quot;
}</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="showcase">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#showcase">#</doc-anchor-trigger>
<span>Showcase</span>
</h2>
</doc-anchor-target>
<p><figure class="content-center">
<img src="../../static/debugger/debugger_demo.png" alt="debugger_demo" class="rounded-image-rounded border-image-border border-image-border-width" />
<figcaption class="caption">debugger_demo</figcaption>
</figure>
</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/differences/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Comparison with CPython</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../features/profiling/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Profiling</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Debugging", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,385 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Comparison with CPython | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Comparison with CPython | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="cpython is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/features/differences/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/features/differences/">
<meta property="og:title" content="Comparison with CPython | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="cpython is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/features/differences/">
<meta property="twitter:title" content="Comparison with CPython | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="cpython is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="comparison-with-cpython" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#comparison-with-cpython">#</doc-anchor-trigger>
<span>Comparison with CPython</span>
</h1>
</doc-anchor-target>
<p><a href="https://github.com/python/cpython">cpython</a> is the reference implementation of the Python programming language. It is written in C and is the most widely used implementation of Python.</p>
<doc-anchor-target id="the-design-goal">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#the-design-goal">#</doc-anchor-trigger>
<span>The design goal</span>
</h2>
</doc-anchor-target>
<p><strong>pkpy aims to be an alternative to lua for
game scripting, not cpython for general purpose programming.</strong></p>
<ul>
<li>For syntax and semantics, pkpy is designed to be as close to cpython as possible.</li>
<li>For ecosystem and others, pkpy is not compatible with cpython.</li>
</ul>
<p>pkpy supports most of the syntax and semantics of python.
For performance and simplicity, some features are not implemented, or behave differently.
The easiest way to test a feature is to <a href="https://pocketpy.dev/static/web/">try it on your browser</a>.</p>
<doc-anchor-target id="unimplemented-features">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#unimplemented-features">#</doc-anchor-trigger>
<span>Unimplemented features</span>
</h2>
</doc-anchor-target>
<ol>
<li>Descriptor protocol <code v-pre>__get__</code> and <code v-pre>__set__</code>. However, <code v-pre>@property</code> is implemented.</li>
<li><code v-pre>__slots__</code> in class definition.</li>
<li><code v-pre>else</code> clause in try..except.</li>
<li>Inplace methods like <code v-pre>__iadd__</code> and <code v-pre>__imul__</code>.</li>
<li><code v-pre>__del__</code> in class definition.</li>
<li>Multiple inheritance.</li>
</ol>
<doc-anchor-target id="different-behaviors">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#different-behaviors">#</doc-anchor-trigger>
<span>Different behaviors</span>
</h2>
</doc-anchor-target>
<ol>
<li>positional and keyword arguments are strictly evaluated.</li>
<li><code v-pre>int</code> does not derive from <code v-pre>bool</code>.</li>
<li><code v-pre>int</code> is 64-bit.</li>
<li>Raw string cannot have boundary quotes in it, even escaped. See <a href="https://github.com/pocketpy/pocketpy/issues/55">#55</a>.</li>
<li>In a starred unpacked assignment, e.g. <code v-pre>a, b, *c = x</code>, the starred variable can only be presented in the last position. <code v-pre>a, *b, c = x</code> is not supported.</li>
<li>A <code v-pre>Tab</code> is equivalent to 4 spaces. You can mix <code v-pre>Tab</code> and spaces in indentation, but it is not recommended.</li>
<li>A return, break, continue in try/except/with block will make the finally block not executed.</li>
<li><code v-pre>match</code> is a keyword and <code v-pre>match..case</code> is equivalent to <code v-pre>if..elif..else</code>.</li>
</ol>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/basic/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Basic Features</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../features/debugging/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Debugging</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Comparison with CPython", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,374 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Profiling | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Profiling | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="To profile your pocketpy program, you can run main.exe with --profile flag.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/features/profiling/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/features/profiling/">
<meta property="og:title" content="Profiling | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="To profile your pocketpy program, you can run main.exe with --profile flag.">
<meta property="og:image" content="https://pocketpy.dev/static/profiler_demo.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/features/profiling/">
<meta property="twitter:title" content="Profiling | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="To profile your pocketpy program, you can run main.exe with --profile flag.">
<meta property="twitter:image" content="https://pocketpy.dev/static/profiler_demo.png">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="profiling" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#profiling">#</doc-anchor-trigger>
<span>Profiling</span>
</h1>
</doc-anchor-target>
<p>To profile your pocketpy program, you can run <code v-pre>main.exe</code> with <code v-pre>--profile</code> flag.</p>
<p>For example, to profile <code v-pre>test/test_math.py</code>, run</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">main.exe --profile test/test_math.py</code></pre>
</doc-codeblock></div>
<p>This will output a JSON report file named <code v-pre>profile_report.json</code> in the current directory,
which records the time spent for each line. To visualize the report, please install our VSCode extension.</p>
<p><a href="https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy">https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy</a></p>
<div class="flex mb-6">
<div class="shrink-0 w-1.5 rounded-tl-lg rounded-bl-lg bg-callout-primary"></div>
<div class="flex w-full py-4 border border-l-0 rounded-tr-lg rounded-br-lg doc-callout bg-callout-base-bg border-callout-base-border" role="alert">
<div class="flex items-center ml-4 h-7">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px text-callout-primary" width="22" height="22" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor"><g>
<path d="M12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9z"></path>
<path d="M12 11c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zM12.01 7c-.56 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path>
<path fill="none" d="M0 0h24v24H0z"></path>
</g></g>
</svg>
</div>
<div class="pr-5 ml-3 w-full">
<p>The VSCode extension requires pocketpy version &gt;= <code v-pre>2.1.1</code></p>
</div>
</div>
</div>
<p>With pocketpy VSCode extension, press <code v-pre>F1</code> and type <code v-pre>pocketpy: Load Line Profiler Report</code>,
select <strong>1. the <code v-pre>profile_report.json</code> file; 2. the source root of the program</strong>. Then you will see a nice visualization of the profiling result.</p>
<p><figure class="content-center">
<img src="../../static/profiler_demo.png" alt="profiler_report" class="rounded-image-rounded border-image-border border-image-border-width" />
<figcaption class="caption">profiler_report</figcaption>
</figure>
</p>
<p>Press <code v-pre>ESC</code> to exit the report view.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/debugging/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Debugging</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../features/threading/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Threading</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Profiling", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,490 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Threading | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Threading | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="pocketpy organizes its state by VM structure. Users can have at maximum 16 VM instances (index from 0 to 15).">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/features/threading/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/features/threading/">
<meta property="og:title" content="Threading | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="pocketpy organizes its state by VM structure. Users can have at maximum 16 VM instances (index from 0 to 15).">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/features/threading/">
<meta property="twitter:title" content="Threading | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="pocketpy organizes its state by VM structure. Users can have at maximum 16 VM instances (index from 0 to 15).">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
<script id="mermaid-js" data-cfasync="false" src="../../resources/js/mermaid.js?v=3.11.0" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="threading" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#threading">#</doc-anchor-trigger>
<span>Threading</span>
</h1>
</doc-anchor-target>
<p>pocketpy organizes its state by <code v-pre>VM</code> structure.
Users can have at maximum 16 <code v-pre>VM</code> instances (index from 0 to 15).
Each <code v-pre>VM</code> instance can only be accessed by exactly one thread at a time.
If you are trying to run two python scripts in parallel refering the same <code v-pre>VM</code> instance,
you will crash it definitely.</p>
<p>However, there are two ways to achieve multi-threading in pocketpy.</p>
<p>One way is to use a native threading library such as <code v-pre>pthread</code>.
You can wrap the multi-threading logic into a C function and bind it to pocketpy.
Be careful and not to access the same <code v-pre>VM</code> instance from multiple threads at the same time.
You need to lock critical resources or perform a deep copy of all needed data.</p>
<doc-anchor-target id="computethread">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#computethread">#</doc-anchor-trigger>
<span>ComputeThread</span>
</h2>
</doc-anchor-target>
<p>The other way is to use <code v-pre>pkpy.ComputeThread</code>.
It is like an isolate in Dart language.
<code v-pre>ComputeThread</code> is a true multi-threading model to allow you run python scripts in parallel without lock,
backed by a separate <code v-pre>VM</code> instance.</p>
<p><code v-pre>ComputeThread</code> is highly designed for computational intensive tasks in games.
For example, you can run game logic in main thread (VM 0) and run world generation in another thread (e.g. VM 1).</p>
<div class="overflow-hidden mb-6 py-4 dark:px-5 dark:bg-white rounded-md"><pre translate="no" class="mermaid w-full">graph TD
subgraph Main Thread
A[Game Start]
B[Submit WorldGen Job]
C[Frame 1]
D[Frame 2]
E[Frame 3]
F[...]
G[Get WorldGen Result]
H[Render World]
end
subgraph WorldGen Thread
O[Generate Biomes]
P[Generate Terrain]
Q[Generate Creatures]
R[Dump Result]
end
A --&gt; B
B --&gt; C
C --&gt; D
D --&gt; E
E --&gt; F
F --&gt; G
G --&gt; H
O --&gt; P
P --&gt; Q
Q --&gt; R
B --&gt; O
R --&gt; G</pre></div>
<doc-anchor-target id="mainpy">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#mainpy">#</doc-anchor-trigger>
<span><code v-pre>main.py</code></span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">import time
from pkpy import ComputeThread
thread = ComputeThread(1)
print(&quot;Game Start&quot;)
# import worldgen.py
thread.exec('from worldgen import gen_world')
print(&quot;Submit WorldGen Job&quot;)
thread.submit_call('gen_world', 3, (100, 100), 10)
# wait for worldgen to finish
for i in range(1, 100000):
print('Frame:', i)
time.sleep(1)
if thread.is_done:
break
error = thread.last_error()
if error is not None:
print(&quot;Error:&quot;, error)
else:
retval = thread.last_retval()
biomes = retval['biomes']
terrain = retval['terrain']
creatures = retval['creatures']
print(&quot;World Generation Complete&quot;, len(biomes), len(terrain), len(creatures))</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="worldgenpy">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#worldgenpy">#</doc-anchor-trigger>
<span><code v-pre>worldgen.py</code></span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">import time
import random
def gen_world(biome_count: int, terrain_size: tuple[int, int], creature_count: int) -&gt; dict:
# simulate a long computation
time.sleep(3)
# generate world data
all_biomes = [&quot;forest&quot;, &quot;desert&quot;, &quot;ocean&quot;, &quot;mountain&quot;, &quot;swamp&quot;]
all_creatures = [&quot;wolf&quot;, &quot;bear&quot;, &quot;fish&quot;, &quot;bird&quot;, &quot;lizard&quot;]
width, height = terrain_size
terrain_data = [
random.randint(1, 10)
for _ in range(width * height)
]
creatures = [
{
&quot;name&quot;: random.choice(all_creatures),
&quot;x&quot;: random.randint(0, width - 1),
&quot;y&quot;: random.randint(0, height - 1),
}
for i in range(creature_count)
]
return {
&quot;biomes&quot;: all_biomes[:biome_count],
&quot;terrain&quot;: terrain_data,
&quot;creatures&quot;: creatures,
}</code></pre>
</doc-codeblock></div>
<p>Run <code v-pre>main.py</code> and you will see the result like this:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">Game Start
Submit WorldGen Job
Frame: 1
Frame: 2
Frame: 3
Frame: 4
World Generation Complete 3 10000 10</code></pre>
</doc-codeblock></div>
<p><code v-pre>ComputeThread</code> uses <code v-pre>pickle</code> module to serialize the data between threads.
Parameters and return values must be supported by <code v-pre>pickle</code>.
See <a href="https://pocketpy.dev/modules/pickle/">pickle</a> for more details.</p>
<p>Since <code v-pre>ComputeThread</code> is backed by a separate <code v-pre>VM</code> instance,
it does not share any state with the main thread
except for the parameters you pass to it.
Therefore, common python modules will be imported twice in each thread.</p>
<p>If you want to identify which VM instance the module is running in,
you can call <code v-pre>pkpy.currentvm</code> or let your <code v-pre>ComputeThread</code> set some special flags
before importing these modules.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/profiling/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Profiling</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../features/ub/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Undefined Behaviour</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Threading", level: 2, icon: "file", hasPrism: true, hasMermaid: true, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

346
features/ub/index.html Normal file
View File

@ -0,0 +1,346 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Undefined Behaviour | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Undefined Behaviour | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="These are the undefined behaviours of pkpy. The behaviour of pkpy is undefined if you do the following things.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/features/ub/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/features/ub/">
<meta property="og:title" content="Undefined Behaviour | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="These are the undefined behaviours of pkpy. The behaviour of pkpy is undefined if you do the following things.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/features/ub/">
<meta property="twitter:title" content="Undefined Behaviour | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="These are the undefined behaviours of pkpy. The behaviour of pkpy is undefined if you do the following things.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="undefined-behaviour" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#undefined-behaviour">#</doc-anchor-trigger>
<span>Undefined Behaviour</span>
</h1>
</doc-anchor-target>
<p>These are the undefined behaviours of pkpy. The behaviour of pkpy is undefined if you do the following things.</p>
<ol>
<li>Delete a builtin object. For example, <code v-pre>del int.__add__</code>.</li>
<li>Call an unbound method with the wrong type of <code v-pre>self</code>. For example, <code v-pre>int.__add__('1', 2)</code>.</li>
<li>Type <code v-pre>T</code>&#x27;s <code v-pre>__new__</code> returns an object that is not an instance of <code v-pre>T</code>.</li>
<li>Call <code v-pre>__new__</code> with a type that is not a subclass of <code v-pre>type</code>.</li>
</ol>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/threading/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Threading</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../c-api/introduction/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Introduction</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Undefined Behaviour", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

407
gsoc2024/guide/index.html Normal file
View File

@ -0,0 +1,407 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Application Guide | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Application Guide | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Before starting, please read the Ideas page and choose a project you are interested in. Set up a C++ compiler, clone pocketpy sources from github and...">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/gsoc2024/guide/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/gsoc2024/guide/">
<meta property="og:title" content="Application Guide | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Before starting, please read the Ideas page and choose a project you are interested in. Set up a C++ compiler, clone pocketpy sources from github and...">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/gsoc2024/guide/">
<meta property="twitter:title" content="Application Guide | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Before starting, please read the Ideas page and choose a project you are interested in. Set up a C++ compiler, clone pocketpy sources from github and...">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="application-guide" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#application-guide">#</doc-anchor-trigger>
<span>Application Guide</span>
</h1>
</doc-anchor-target>
<p>Before starting, please read the <a href="../ideas/">Ideas</a> page and choose a project you are interested in.
Set up a C++ compiler, clone pocketpy sources from github and try to build.
This helps you confirm that your skills and experience match the requirements of the project.</p>
<doc-anchor-target id="build-guide-for-beginners">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#build-guide-for-beginners">#</doc-anchor-trigger>
<span>Build guide for beginners</span>
</h3>
</doc-anchor-target>
<p>First, you need to install these tools:</p>
<ol>
<li>Python(&gt;= 3.8), I am sure you already have it.</li>
<li>A C++ compiler, such as GCC, Clang or MSVC. If you are on Linux, <code v-pre>gcc</code> and <code v-pre>g++</code> are already installed. If you are on Windows, you can install Visual Studio with C++ development tools.</li>
<li>CMake(&gt;= 3.10), a cross-platform build tool. You can use <code v-pre>pip install cmake</code> to install it.</li>
</ol>
<p>Then, clone pocketpy sources from github and try to build:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-bash"><code v-pre class="language-bash">git clone https://github.com/pocketpy/pocketpy
cd pocketpy
python cmake_build.py</code></pre>
</doc-codeblock></div>
<p>If everything goes well, you will get a <code v-pre>main</code> executable (<code v-pre>main.exe</code> on Windows) in the root directory of pocketpy.
Simply run it and you will enter pocketpy&#x27;s REPL.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">pocketpy 1.4.0 (Jan 24 2024, 12:39:13) [32 bit] on emscripten
https://github.com/pocketpy/pocketpy
Type &quot;exit()&quot; to exit.
&gt;&gt;&gt;
&gt;&gt;&gt; &quot;Hello, world&quot;
'Hello, world'</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="application-guide">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#application-guide">#</doc-anchor-trigger>
<span>Application guide</span>
</h3>
</doc-anchor-target>
<p><strong>Your need to send an email to <code v-pre>blueloveth@foxmail.com</code> with the following information:</strong></p>
<ol>
<li>A brief introduction about yourself, including the most related open sourced project you have worked on before. It is highly recommended to attach your Github profile link.</li>
<li>A technical proposal for the project you are interested in working on, including:
<ul>
<li>Your understanding of the project.</li>
<li>The technical approach/architecture you will adopt.</li>
<li>The challenges you might face and how you will overcome them.</li>
</ul>
</li>
<li>A timeline for the project, including the milestones and deliverables.</li>
<li>Other information required by the Google Summer of Code program.</li>
</ol>
<doc-anchor-target id="coding-style-guide">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#coding-style-guide">#</doc-anchor-trigger>
<span>Coding style guide</span>
</h3>
</doc-anchor-target>
<p>See <a href="../../coding-style-guide/">Coding Style Guide</a>.</p>
<doc-anchor-target id="contact-us">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#contact-us">#</doc-anchor-trigger>
<span>Contact us</span>
</h3>
</doc-anchor-target>
<p>If you have any questions, you can join our <a href="https://discord.gg/WWaq72GzXv">Discord</a>
or contact me via email.
We are glad to help you with your application.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2025/ideas/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Project Ideas</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2024/ideas/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Project Ideas</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Application Guide", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

383
gsoc2024/ideas/index.html Normal file
View File

@ -0,0 +1,383 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Project Ideas | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Project Ideas | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Difficulty Level: 5/5 (Hard)">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/gsoc2024/ideas/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/gsoc2024/ideas/">
<meta property="og:title" content="Project Ideas | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Difficulty Level: 5/5 (Hard)">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/gsoc2024/ideas/">
<meta property="twitter:title" content="Project Ideas | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Difficulty Level: 5/5 (Hard)">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="project-ideas" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#project-ideas">#</doc-anchor-trigger>
<span>Project Ideas</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="implement-pybind11-for-bindings">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#implement-pybind11-for-bindings">#</doc-anchor-trigger>
<span>Implement pybind11 for bindings</span>
</h3>
</doc-anchor-target>
<ul>
<li>Difficulty Level: 5/5 (Hard)</li>
<li>Skill: Advanced C++ with metaprogramming; Python</li>
<li>Project Length: Medium (175 hours)</li>
</ul>
<blockquote>
<p><a href="https://summerofcode.withgoogle.com/archive/2024/projects/Ji2Mi97o">https://summerofcode.withgoogle.com/archive/2024/projects/Ji2Mi97o</a></p>
</blockquote>
<p>pocketpy has provided a low-level API for creating bindings. It is fast, lightweight and easy to debug.
However, it still requires a lot of boilerplate code to create bindings for complex C++ classes.
The community has long expected a high-level API for creating bindings.</p>
<p><a href="https://github.com/pybind/pybind11">pybind11</a>
is the most popular C++ library for creating Python bindings for CPython. A bunch of Python libraries are using it. pybind11 adopts a template metaprogramming approach to automatically generate bindings for C++ classes.</p>
<p>Our goal is to introduce a pybind11 compatible solution to pocketpy as an alternative way to create bindings
for functions and classes.
You can use C++17 features to implement it, instead of C++11 used in pybind11.</p>
<p>See <a href="https://github.com/pocketpy/pocketpy/issues/216">https://github.com/pocketpy/pocketpy/issues/216</a> for more details.</p>
<doc-anchor-target id="add-numpy-module">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#add-numpy-module">#</doc-anchor-trigger>
<span>Add <code v-pre>numpy</code> module</span>
</h3>
</doc-anchor-target>
<ul>
<li>Difficulty Level: 4/5 (Intermediate)</li>
<li>Skill: Intermediate C++; Python; Linear Algebra</li>
<li>Project Length: Medium (175 hours)</li>
</ul>
<blockquote>
<p><a href="https://summerofcode.withgoogle.com/archive/2024/projects/sJLuASSP">https://summerofcode.withgoogle.com/archive/2024/projects/sJLuASSP</a></p>
</blockquote>
<p>Though pocketpy is designed for game scripting,
some people are using it for scientific computing.
It would be nice to have a <code v-pre>numpy</code> module in pocketpy.</p>
<p><code v-pre>numpy</code> is a huge project.
Our goal is to implement a most commonly used subset of <code v-pre>numpy</code> in pocketpy.
You can mix C++ and Python code to simplify the overall workloads.</p>
<p>See <a href="https://github.com/pocketpy/pocketpy/issues/202">https://github.com/pocketpy/pocketpy/issues/202</a> for more details.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2024/guide/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Application Guide</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../coding-style-guide/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Coding Style Guide</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Project Ideas", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

407
gsoc2025/guide/index.html Normal file
View File

@ -0,0 +1,407 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Application Guide | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Application Guide | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Before starting, please read the Ideas page and choose a project you are interested in. Set up a C11 compiler, clone pocketpy sources from github and...">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/gsoc2025/guide/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/gsoc2025/guide/">
<meta property="og:title" content="Application Guide | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Before starting, please read the Ideas page and choose a project you are interested in. Set up a C11 compiler, clone pocketpy sources from github and...">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/gsoc2025/guide/">
<meta property="twitter:title" content="Application Guide | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Before starting, please read the Ideas page and choose a project you are interested in. Set up a C11 compiler, clone pocketpy sources from github and...">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="application-guide" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#application-guide">#</doc-anchor-trigger>
<span>Application Guide</span>
</h1>
</doc-anchor-target>
<p>Before starting, please read the <a href="../ideas/">Ideas</a> page and choose a project you are interested in.
Set up a C11 compiler, clone pocketpy sources from github and try to build.
This helps you confirm that your skills and experience match the requirements of the project.</p>
<doc-anchor-target id="build-guide-for-beginners">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#build-guide-for-beginners">#</doc-anchor-trigger>
<span>Build guide for beginners</span>
</h3>
</doc-anchor-target>
<p>First, you need to install these tools:</p>
<ol>
<li>Python(&gt;= 3.8), I am sure you already have it.</li>
<li>A C11 compiler, such as GCC, Clang or MSVC. If you are on Linux, <code v-pre>gcc</code> is already installed. If you are on Windows, you can install Visual Studio with C/C++ development tools.</li>
<li>CMake(&gt;= 3.10), a cross-platform build tool. You can use <code v-pre>pip install cmake</code> to install it.</li>
</ol>
<p>Then, clone pocketpy sources from github and try to build:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-bash"><code v-pre class="language-bash">git clone https://github.com/pocketpy/pocketpy
cd pocketpy
python cmake_build.py</code></pre>
</doc-codeblock></div>
<p>If everything goes well, you will get a <code v-pre>main</code> executable (<code v-pre>main.exe</code> on Windows) in the root directory of pocketpy.
Simply run it and you will enter pocketpy&#x27;s REPL.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">pocketpy 2.0.5 (Jan 17 2025, 14:36:15) [64 bit] on darwin
https://github.com/pocketpy/pocketpy
Type &quot;exit()&quot; to exit.
&gt;&gt;&gt;
&gt;&gt;&gt; &quot;Hello, world&quot;
'Hello, world'</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="application-guide">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#application-guide">#</doc-anchor-trigger>
<span>Application guide</span>
</h3>
</doc-anchor-target>
<p><strong>Your need to send an email to <code v-pre>blueloveth@foxmail.com</code> with the following information:</strong></p>
<ol>
<li>A brief introduction about yourself, including the most related open sourced project you have worked on before. It is highly recommended to attach your Github profile link.</li>
<li>A technical proposal for the project you are interested in working on, including:
<ul>
<li>Your understanding of the project.</li>
<li>The technical approach/architecture you will adopt.</li>
<li>The challenges you might face and how you will overcome them.</li>
</ul>
</li>
<li>A timeline for the project, including the milestones and deliverables.</li>
<li>Other information required by the Google Summer of Code program.</li>
</ol>
<doc-anchor-target id="coding-style-guide">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#coding-style-guide">#</doc-anchor-trigger>
<span>Coding style guide</span>
</h3>
</doc-anchor-target>
<p>See <a href="../../coding-style-guide/">Coding Style Guide</a>.</p>
<doc-anchor-target id="contact-us">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#contact-us">#</doc-anchor-trigger>
<span>Contact us</span>
</h3>
</doc-anchor-target>
<p>If you have any questions, you can join our <a href="https://discord.gg/WWaq72GzXv">Discord</a>
or contact me via email.
We are glad to help you with your application.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/vmath/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">vmath</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2025/ideas/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Project Ideas</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Application Guide", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

369
gsoc2025/ideas/index.html Normal file
View File

@ -0,0 +1,369 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Project Ideas | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Project Ideas | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Difficulty Level: 3/5 (Medium)">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/gsoc2025/ideas/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/gsoc2025/ideas/">
<meta property="og:title" content="Project Ideas | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Difficulty Level: 3/5 (Medium)">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/gsoc2025/ideas/">
<meta property="twitter:title" content="Project Ideas | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Difficulty Level: 3/5 (Medium)">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="project-ideas" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#project-ideas">#</doc-anchor-trigger>
<span>Project Ideas</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="vscode-plugin-for-debugging-pocketpy-applications">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#vscode-plugin-for-debugging-pocketpy-applications">#</doc-anchor-trigger>
<span>VSCode plugin for debugging pocketpy applications</span>
</h3>
</doc-anchor-target>
<ul>
<li>Difficulty Level: 3/5 (Medium)</li>
<li>Skill: TypeScript; C</li>
<li>Project Length: Medium</li>
</ul>
<p>Community users have reported that there is no convenient way to debug python applications interpreted by pocketpy. Fortunately, VSCode provides a mechanism of <a href="https://code.visualstudio.com/api/extension-guides/debugger-extension">Debugger Extension</a> that allows us to integrate pocketpy debugger into VSCode UI through Debug Adapter Protocol (DAP).</p>
<p>This project aims to develop a VSCode plugin like <a href="https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy">Python Debugger</a>, which implements DAP for pocketpy. With this plugin, users can launch their pocketpy applications in VSCode with breakpoints, call stacks, and variable inspection. Students with experience in TypeScript will be helpful for this project.</p>
<doc-anchor-target id="develop-math-operators-for-ctensor-library">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#develop-math-operators-for-ctensor-library">#</doc-anchor-trigger>
<span>Develop math operators for <code v-pre>cTensor</code> library</span>
</h3>
</doc-anchor-target>
<ul>
<li>Difficulty Level: 4/5 (Hard)</li>
<li>Skill: C; Further Mathematics</li>
<li>Project Length: Small or Medium</li>
</ul>
<p>pocketpy is providing a tensor library <code v-pre>cTensor</code> for users who want to integrate neural networks into their applications. <code v-pre>cTensor</code> implements automatic differentiation and dynamic compute graph. It allows users to train and deploy neural networks on client-side devices like mobile phones and microcontrollers (e.g. ESP32-C3). We have a runable prototype located at <a href="https://github.com/pocketpy/cTensor">pocketpy/cTensor</a>. But math operators have not been implemented yet.</p>
<p>In this project, students will develop forward and backward math operators, as well as basic neural network layers and optimizers (e.g. SGD, Adam). The project is written in C11.
We expect students to have a good understanding of further mathematics and C programming.</p>
<blockquote>
<p>This year we also accept custom project ideas. If you are not interested in the above, you can propose your own idea and contact me via <code v-pre>blueloveth@foxmail.com</code>. We will discuss the feasibility and mentorship for your idea.</p>
</blockquote>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2025/guide/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Application Guide</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2024/guide/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Application Guide</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Project Ideas", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

407
index.html Normal file
View File

@ -0,0 +1,407 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Welcome to pocketpy | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Welcome to pocketpy | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="pocketpy is a portable Python 3.x interpreter, written in C11. It aims to be an alternative to Lua for game scripting, with elegant syntax, powerful...">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/">
<meta property="og:title" content="Welcome to pocketpy | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="pocketpy is a portable Python 3.x interpreter, written in C11. It aims to be an alternative to Lua for game scripting, with elegant syntax, powerful...">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/">
<meta property="twitter:title" content="Welcome to pocketpy | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="pocketpy is a portable Python 3.x interpreter, written in C11. It aims to be an alternative to Lua for game scripting, with elegant syntax, powerful...">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="static/logo.png" rel="icon">
<link href="resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="welcome-to-pocketpy" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#welcome-to-pocketpy">#</doc-anchor-trigger>
<span>Welcome to pocketpy</span>
</h1>
</doc-anchor-target>
<p>pocketpy is a portable Python 3.x interpreter, written in C11.
It aims to be an alternative to Lua for game scripting, with elegant syntax, powerful features and competitive performance.
pocketpy has no dependencies other than the C standard library, which can be easily integrated into your C/C++ project.
Developers are able to write Python bindings via C-API or pybind11 compatible interfaces.</p>
<ul>
<li><a href="https://pocketpy.dev/static/web/">Live Python Demo</a>: Run Python code in your browser</li>
<li><a href="https://pocketpy.github.io/examples/">Live C Examples</a>: Explore C-APIs in your browser</li>
<li><a href="https://github.com/pocketpy/godot-pocketpy">Godot Extension</a>: Use pocketpy in Godot Engine</li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy">VSCode Extension</a>: Debug and profile pocketpy scripts in VSCode</li>
<li><a href="https://pub.dev/packages/pocketpy">Flutter Plugin</a>: Use pocketpy in Flutter apps</li>
</ul>
<doc-anchor-target id="what-it-looks-like">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#what-it-looks-like">#</doc-anchor-trigger>
<span>What it looks like</span>
</h2>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">def is_prime(x):
if x &lt; 2:
return False
for i in range(2, x):
if x % i == 0:
return False
return True
primes = [i for i in range(2, 20) if is_prime(i)]
print(primes)
# [2, 3, 5, 7, 11, 13, 17, 19]</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="supported-platforms">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#supported-platforms">#</doc-anchor-trigger>
<span>Supported platforms</span>
</h2>
</doc-anchor-target>
<p>pkpy should work on any platform with a C11 compiler.
These platforms are officially tested.</p>
<ul>
<li>Windows 64-bit</li>
<li>Linux 64-bit / 32-bit</li>
<li>macOS 64-bit</li>
<li>Android 64-bit / 32-bit</li>
<li>iOS 64-bit</li>
<li>Emscripten 32-bit</li>
<li>Raspberry Pi OS 64-bit</li>
</ul>
<doc-anchor-target id="star-the-repo">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#star-the-repo">#</doc-anchor-trigger>
<span>Star the repo</span>
</h2>
</doc-anchor-target>
<p>If you find pkpy useful, consider <a href="https://github.com/blueloveth/pocketpy">star this repository</a> (●&#x27;&#x27;●)</p>
<doc-anchor-target id="sponsor-this-project">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#sponsor-this-project">#</doc-anchor-trigger>
<span>Sponsor this project</span>
</h2>
</doc-anchor-target>
<p>You can sponsor this project via these ways.</p>
<ul>
<li><a href="https://github.com/sponsors/blueloveTH">Github Sponsors</a></li>
<li><a href="https://www.buymeacoffee.com/blueloveth">Buy me a coffee</a></li>
</ul>
<p>Your sponsorship will help us develop pkpy continuously.</p>
<doc-anchor-target id="upgrade-to-v20">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#upgrade-to-v20">#</doc-anchor-trigger>
<span>Upgrade to v2.0</span>
</h2>
</doc-anchor-target>
<p>pkpy v2.0 is a C11 project instead of C++17. All your existing code for v1.x won&#x27;t work anymore.</p>
<p>We provide two API sets for v2.0, C-API and pybind11 API (C++17). If you are a C user, use the C-API. If you are a C++ user, use the pybind11 API.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l rounded-r-lg transition-colors duration-150 relative hover:z-5" href="quick-start/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Quick Start</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Welcome", isRoot: true, level: 0, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

356
license/index.html Normal file
View File

@ -0,0 +1,356 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>License | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="License | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="pkpy is licensed under the MIT License.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/license/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/license/">
<meta property="og:title" content="License | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="pkpy is licensed under the MIT License.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/license/">
<meta property="twitter:title" content="License | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="pkpy is licensed under the MIT License.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../static/logo.png" rel="icon">
<link href="../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="license" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#license">#</doc-anchor-trigger>
<span>License</span>
</h1>
</doc-anchor-target>
<p>pkpy is licensed under the <a href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">MIT License
Copyright (c) 2025 blueloveTH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../performance/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Performance</span>
</span>
</a>
</div>
<div class="w-1/2">
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "License", level: 1, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

517
modules/array2d/index.html Normal file
View File

@ -0,0 +1,517 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>array2d | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="array2d | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Efficient general-purpose 2D array.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/array2d/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/array2d/">
<meta property="og:title" content="array2d | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Efficient general-purpose 2D array.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/array2d/">
<meta property="twitter:title" content="array2d | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Efficient general-purpose 2D array.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="array2d" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#array2d">#</doc-anchor-trigger>
<span>array2d</span>
</h1>
</doc-anchor-target>
<p>Efficient general-purpose 2D array.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from typing import Callable, Literal, overload, Iterator, Self
from vmath import vec2i
Neighborhood = Literal['Moore', 'von Neumann']
class array2d_like[T]:
@property
def n_cols(self) -&gt; int: ...
@property
def n_rows(self) -&gt; int: ...
@property
def width(self) -&gt; int: ...
@property
def height(self) -&gt; int: ...
@property
def shape(self) -&gt; vec2i: ...
@property
def numel(self) -&gt; int: ...
@overload
def is_valid(self, col: int, row: int) -&gt; bool: ...
@overload
def is_valid(self, pos: vec2i) -&gt; bool: ...
def get[R](self, col: int, row: int, default: R = None) -&gt; T | R:
&quot;&quot;&quot;Get the value at the given position.
If the position is out of bounds, returns the default value.
&quot;&quot;&quot;
def index(self, value: T) -&gt; vec2i:
&quot;&quot;&quot;Get the position of the first occurrence of the given value.
Raises `ValueError` if the value is not found.
&quot;&quot;&quot;
def render(self) -&gt; str: ...
def all(self: array2d_like[bool]) -&gt; bool: ...
def any(self: array2d_like[bool]) -&gt; bool: ...
def map[R](self, f: Callable[[T], R]) -&gt; array2d[R]: ...
def apply(self, f: Callable[[T], T]) -&gt; None: ...
def zip_with[R, U](self, other: array2d_like[U], f: Callable[[T, U], R]) -&gt; array2d[R]: ...
def copy(self) -&gt; 'array2d[T]': ...
def tolist(self) -&gt; list[list[T]]: ...
def __le__(self, other: T | array2d_like[T]) -&gt; array2d[bool]: ...
def __lt__(self, other: T | array2d_like[T]) -&gt; array2d[bool]: ...
def __ge__(self, other: T | array2d_like[T]) -&gt; array2d[bool]: ...
def __gt__(self, other: T | array2d_like[T]) -&gt; array2d[bool]: ...
def __eq__(self, other: T | array2d_like[T]) -&gt; array2d[bool]: ... # type: ignore
def __ne__(self, other: T | array2d_like[T]) -&gt; array2d[bool]: ... # type: ignore
def __add__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __sub__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __mul__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __truediv__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __floordiv__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __mod__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __pow__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __and__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __or__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __xor__(self, other: T | array2d_like[T]) -&gt; array2d[T]: ...
def __invert__(self) -&gt; array2d[T]: ...
def __iter__(self) -&gt; Iterator[tuple[vec2i, T]]: ...
def __repr__(self) -&gt; str: ...
@overload
def __getitem__(self, index: vec2i) -&gt; T: ...
@overload
def __getitem__(self, index: tuple[int, int]) -&gt; T: ...
@overload
def __getitem__(self, index: tuple[slice, slice]) -&gt; array2d_view[T]: ...
@overload
def __getitem__(self, index: tuple[slice, int] | tuple[int, slice]) -&gt; array2d_view[T]: ...
@overload
def __getitem__(self, mask: array2d_like[bool]) -&gt; list[T]: ...
@overload
def __setitem__(self, index: vec2i, value: T): ...
@overload
def __setitem__(self, index: tuple[int, int], value: T): ...
@overload
def __setitem__(self, index: tuple[slice, slice], value: T | 'array2d_like[T]'): ...
@overload
def __setitem__(self, index: tuple[slice, int] | tuple[int, slice], value: T | 'array2d_like[T]'): ...
@overload
def __setitem__(self, mask: array2d_like[bool], value: T): ...
# algorithms
def count(self, value: T) -&gt; int:
&quot;&quot;&quot;Count the number of cells with the given value.&quot;&quot;&quot;
def count_neighbors(self, value: T, neighborhood: Neighborhood) -&gt; array2d[int]:
&quot;&quot;&quot;Count the number of neighbors with the given value for each cell.&quot;&quot;&quot;
def get_bounding_rect(self, value: T) -&gt; tuple[int, int, int, int]:
&quot;&quot;&quot;Get the bounding rectangle of the given value.
Returns a tuple `(x, y, width, height)` or raise `ValueError` if the value is not found.
&quot;&quot;&quot;
def convolve(self: array2d_like[int], kernel: array2d_like[int], padding: int) -&gt; array2d[int]:
&quot;&quot;&quot;Convolve the array with the given kernel.&quot;&quot;&quot;
def get_connected_components(self, value: T, neighborhood: Neighborhood) -&gt; tuple[array2d[int], int]:
&quot;&quot;&quot;Get connected components of the grid via BFS algorithm.
Returns the `visited` array and the number of connected components,
where `0` means unvisited, and non-zero means the index of the connected component.
&quot;&quot;&quot;
class array2d_view[T](array2d_like[T]):
@property
def origin(self) -&gt; vec2i: ...
class array2d[T](array2d_like[T]):
def __new__(
cls,
n_cols: int,
n_rows: int,
default: T | Callable[[vec2i], T] | None = None
): ...
@staticmethod
def fromlist(data: list[list[T]]) -&gt; array2d[T]: ...
class chunked_array2d[T, TContext]:
def __new__(
cls,
chunk_size: int,
default: T = None,
context_builder: Callable[[vec2i], TContext] | None = None,
): ...
@property
def chunk_size(self) -&gt; int: ...
@property
def default(self) -&gt; T: ...
@property
def context_builder(self) -&gt; Callable[[vec2i], TContext] | None: ...
def __getitem__(self, index: vec2i) -&gt; T: ...
def __setitem__(self, index: vec2i, value: T): ...
def __delitem__(self, index: vec2i): ...
def __iter__(self) -&gt; Iterator[tuple[vec2i, TContext]]: ...
def __len__(self) -&gt; int: ...
def clear(self) -&gt; None: ...
def copy(self) -&gt; Self: ...
def world_to_chunk(self, world_pos: vec2i) -&gt; tuple[vec2i, vec2i]:
&quot;&quot;&quot;Converts world position to chunk position and local position.&quot;&quot;&quot;
def add_chunk(self, chunk_pos: vec2i) -&gt; TContext: ...
def remove_chunk(self, chunk_pos: vec2i) -&gt; bool: ...
def move_chunk(self, src_chunk_pos: vec2i, dst_chunk_pos: vec2i) -&gt; bool: ...
def get_context(self, chunk_pos: vec2i) -&gt; TContext | None: ...
def view(self) -&gt; array2d_view[T]: ...
def view_rect(self, pos: vec2i, width: int, height: int) -&gt; array2d_view[T]: ...
def view_chunk(self, chunk_pos: vec2i) -&gt; array2d_view[T]: ...
def view_chunks(self, chunk_pos: vec2i, width: int, height: int) -&gt; array2d_view[T]: ...</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../c-api/functions/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Functions</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/base64/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">base64</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "array2d", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

353
modules/base64/index.html Normal file
View File

@ -0,0 +1,353 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>base64 | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="base64 | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Encode bytes-like object b using the standard Base64 alphabet.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/base64/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/base64/">
<meta property="og:title" content="base64 | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Encode bytes-like object b using the standard Base64 alphabet.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/base64/">
<meta property="twitter:title" content="base64 | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Encode bytes-like object b using the standard Base64 alphabet.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="base64" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#base64">#</doc-anchor-trigger>
<span>base64</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="base64b64encodeb-bytes---bytes">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#base64b64encodeb-bytes---bytes">#</doc-anchor-trigger>
<span><code v-pre>base64.b64encode(b: bytes) -&gt; bytes</code></span>
</h3>
</doc-anchor-target>
<p>Encode bytes-like object <code v-pre>b</code> using the standard Base64 alphabet.</p>
<doc-anchor-target id="base64b64decodeb-str--bytes---bytes">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#base64b64decodeb-str--bytes---bytes">#</doc-anchor-trigger>
<span><code v-pre>base64.b64decode(b: str | bytes) -&gt; bytes</code></span>
</h3>
</doc-anchor-target>
<p>Decode Base64 encoded bytes-like object <code v-pre>b</code>.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/array2d/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">array2d</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/bisect/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">bisect</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "base64", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

450
modules/bisect/index.html Normal file
View File

@ -0,0 +1,450 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>bisect | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="bisect | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Return the index where to insert item x in list a, assuming a is sorted.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/bisect/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/bisect/">
<meta property="og:title" content="bisect | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Return the index where to insert item x in list a, assuming a is sorted.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/bisect/">
<meta property="twitter:title" content="bisect | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Return the index where to insert item x in list a, assuming a is sorted.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="bisect" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#bisect">#</doc-anchor-trigger>
<span>bisect</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="bisectbisect_lefta-x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#bisectbisect_lefta-x">#</doc-anchor-trigger>
<span><code v-pre>bisect.bisect_left(a, x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the index where to insert item <code v-pre>x</code> in list <code v-pre>a</code>, assuming <code v-pre>a</code> is sorted.</p>
<doc-anchor-target id="bisectbisect_righta-x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#bisectbisect_righta-x">#</doc-anchor-trigger>
<span><code v-pre>bisect.bisect_right(a, x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the index where to insert item <code v-pre>x</code> in list <code v-pre>a</code>, assuming <code v-pre>a</code> is sorted.</p>
<doc-anchor-target id="bisectinsort_lefta-x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#bisectinsort_lefta-x">#</doc-anchor-trigger>
<span><code v-pre>bisect.insort_left(a, x)</code></span>
</h3>
</doc-anchor-target>
<p>Insert item <code v-pre>x</code> in list <code v-pre>a</code>, and keep it sorted assuming <code v-pre>a</code> is sorted.</p>
<p>If x is already in a, insert it to the left of the leftmost x.</p>
<doc-anchor-target id="bisectinsort_righta-x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#bisectinsort_righta-x">#</doc-anchor-trigger>
<span><code v-pre>bisect.insort_right(a, x)</code></span>
</h3>
</doc-anchor-target>
<p>Insert item <code v-pre>x</code> in list <code v-pre>a</code>, and keep it sorted assuming <code v-pre>a</code> is sorted.</p>
<p>If x is already in a, insert it to the right of the rightmost x.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">&quot;&quot;&quot;Bisection algorithms.&quot;&quot;&quot;
def insort_right(a, x, lo=0, hi=None):
&quot;&quot;&quot;Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the right of the rightmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
&quot;&quot;&quot;
lo = bisect_right(a, x, lo, hi)
a.insert(lo, x)
def bisect_right(a, x, lo=0, hi=None):
&quot;&quot;&quot;Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e &lt;= x, and all e in
a[i:] have e &gt; x. So if x already appears in the list, a.insert(x) will
insert just after the rightmost x already there.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
&quot;&quot;&quot;
if lo &lt; 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo &lt; hi:
mid = (lo+hi)//2
if x &lt; a[mid]: hi = mid
else: lo = mid+1
return lo
def insort_left(a, x, lo=0, hi=None):
&quot;&quot;&quot;Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the left of the leftmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
&quot;&quot;&quot;
lo = bisect_left(a, x, lo, hi)
a.insert(lo, x)
def bisect_left(a, x, lo=0, hi=None):
&quot;&quot;&quot;Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e &lt; x, and all e in
a[i:] have e &gt;= x. So if x already appears in the list, a.insert(x) will
insert just before the leftmost x already there.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
&quot;&quot;&quot;
if lo &lt; 0:
raise ValueError('lo must be non-negative')
if hi is None:
hi = len(a)
while lo &lt; hi:
mid = (lo+hi)//2
if a[mid] &lt; x: lo = mid+1
else: hi = mid
return lo
# Create aliases
bisect = bisect_right
insort = insort_right</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/base64/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">base64</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/cmath/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">cmath</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "bisect", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

537
modules/cmath/index.html Normal file
View File

@ -0,0 +1,537 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>cmath | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="cmath | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Mathematical functions for complex numbers.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/cmath/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/cmath/">
<meta property="og:title" content="cmath | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Mathematical functions for complex numbers.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/cmath/">
<meta property="twitter:title" content="cmath | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Mathematical functions for complex numbers.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="cmath" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#cmath">#</doc-anchor-trigger>
<span>cmath</span>
</h1>
</doc-anchor-target>
<p>Mathematical functions for complex numbers.</p>
<p><a href="https://docs.python.org/3/library/cmath.html">https://docs.python.org/3/library/cmath.html</a></p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">import math
class complex:
def __init__(self, real, imag=0):
self._real = float(real)
self._imag = float(imag)
@property
def real(self):
return self._real
@property
def imag(self):
return self._imag
def conjugate(self):
return complex(self.real, -self.imag)
def __repr__(self):
s = ['(', str(self.real)]
s.append('-' if self.imag &lt; 0 else '+')
s.append(str(abs(self.imag)))
s.append('j)')
return ''.join(s)
def __eq__(self, other):
if type(other) is complex:
return self.real == other.real and self.imag == other.imag
if type(other) in (int, float):
return self.real == other and self.imag == 0
return NotImplemented
def __ne__(self, other):
res = self == other
if res is NotImplemented:
return res
return not res
def __add__(self, other):
if type(other) is complex:
return complex(self.real + other.real, self.imag + other.imag)
if type(other) in (int, float):
return complex(self.real + other, self.imag)
return NotImplemented
def __radd__(self, other):
return self.__add__(other)
def __sub__(self, other):
if type(other) is complex:
return complex(self.real - other.real, self.imag - other.imag)
if type(other) in (int, float):
return complex(self.real - other, self.imag)
return NotImplemented
def __rsub__(self, other):
if type(other) is complex:
return complex(other.real - self.real, other.imag - self.imag)
if type(other) in (int, float):
return complex(other - self.real, -self.imag)
return NotImplemented
def __mul__(self, other):
if type(other) is complex:
return complex(self.real * other.real - self.imag * other.imag,
self.real * other.imag + self.imag * other.real)
if type(other) in (int, float):
return complex(self.real * other, self.imag * other)
return NotImplemented
def __rmul__(self, other):
return self.__mul__(other)
def __truediv__(self, other):
if type(other) is complex:
denominator = other.real ** 2 + other.imag ** 2
real_part = (self.real * other.real + self.imag * other.imag) / denominator
imag_part = (self.imag * other.real - self.real * other.imag) / denominator
return complex(real_part, imag_part)
if type(other) in (int, float):
return complex(self.real / other, self.imag / other)
return NotImplemented
def __pow__(self, other: int | float):
if type(other) in (int, float):
return complex(self.__abs__() ** other * math.cos(other * phase(self)),
self.__abs__() ** other * math.sin(other * phase(self)))
return NotImplemented
def __abs__(self) -&gt; float:
return math.sqrt(self.real ** 2 + self.imag ** 2)
def __neg__(self):
return complex(-self.real, -self.imag)
def __hash__(self):
return hash((self.real, self.imag))
# Conversions to and from polar coordinates
def phase(z: complex):
return math.atan2(z.imag, z.real)
def polar(z: complex):
return z.__abs__(), phase(z)
def rect(r: float, phi: float):
return r * math.cos(phi) + r * math.sin(phi) * 1j
# Power and logarithmic functions
def exp(z: complex):
return math.exp(z.real) * rect(1, z.imag)
def log(z: complex, base=2.718281828459045):
return math.log(z.__abs__(), base) + phase(z) * 1j
def log10(z: complex):
return log(z, 10)
def sqrt(z: complex):
return z ** 0.5
# Trigonometric functions
def acos(z: complex):
return -1j * log(z + sqrt(z * z - 1))
def asin(z: complex):
return -1j * log(1j * z + sqrt(1 - z * z))
def atan(z: complex):
return 1j / 2 * log((1 - 1j * z) / (1 + 1j * z))
def cos(z: complex):
return (exp(z) + exp(-z)) / 2
def sin(z: complex):
return (exp(z) - exp(-z)) / (2 * 1j)
def tan(z: complex):
return sin(z) / cos(z)
# Hyperbolic functions
def acosh(z: complex):
return log(z + sqrt(z * z - 1))
def asinh(z: complex):
return log(z + sqrt(z * z + 1))
def atanh(z: complex):
return 1 / 2 * log((1 + z) / (1 - z))
def cosh(z: complex):
return (exp(z) + exp(-z)) / 2
def sinh(z: complex):
return (exp(z) - exp(-z)) / 2
def tanh(z: complex):
return sinh(z) / cosh(z)
# Classification functions
def isfinite(z: complex):
return math.isfinite(z.real) and math.isfinite(z.imag)
def isinf(z: complex):
return math.isinf(z.real) or math.isinf(z.imag)
def isnan(z: complex):
return math.isnan(z.real) or math.isnan(z.imag)
def isclose(a: complex, b: complex):
return math.isclose(a.real, b.real) and math.isclose(a.imag, b.imag)
# Constants
pi = math.pi
e = math.e
tau = 2 * pi
inf = math.inf
infj = complex(0, inf)
nan = math.nan
nanj = complex(0, nan)</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/bisect/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">bisect</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/collections/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">collections</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "cmath", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,537 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>collections | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="collections | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Return a dict containing the counts of each element in iterable.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/collections/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/collections/">
<meta property="og:title" content="collections | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Return a dict containing the counts of each element in iterable.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/collections/">
<meta property="twitter:title" content="collections | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Return a dict containing the counts of each element in iterable.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="collections" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#collections">#</doc-anchor-trigger>
<span>collections</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="collectionscounteriterable">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#collectionscounteriterable">#</doc-anchor-trigger>
<span><code v-pre>collections.Counter(iterable)</code></span>
</h3>
</doc-anchor-target>
<p>Return a <code v-pre>dict</code> containing the counts of each element in <code v-pre>iterable</code>.</p>
<doc-anchor-target id="collectionsdeque">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#collectionsdeque">#</doc-anchor-trigger>
<span><code v-pre>collections.deque</code></span>
</h3>
</doc-anchor-target>
<p>A double-ended queue.</p>
<doc-anchor-target id="collectionsdefaultdict">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#collectionsdefaultdict">#</doc-anchor-trigger>
<span><code v-pre>collections.defaultdict</code></span>
</h3>
</doc-anchor-target>
<p>A dictionary that returns a default value when a key is not found.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from typing import TypeVar, Iterable
def Counter[T](iterable: Iterable[T]):
a: dict[T, int] = {}
for x in iterable:
if x in a:
a[x] += 1
else:
a[x] = 1
return a
class defaultdict(dict):
def __init__(self, default_factory, *args):
super().__init__(*args)
self.default_factory = default_factory
def __missing__(self, key):
self[key] = self.default_factory()
return self[key]
def __repr__(self) -&gt; str:
return f&quot;defaultdict({self.default_factory}, {super().__repr__()})&quot;
def copy(self):
return defaultdict(self.default_factory, self)
class deque[T]:
_head: int
_tail: int
_maxlen: int | None
_capacity: int
_data: list[T]
def __init__(self, iterable: Iterable[T] = None, maxlen: int | None = None):
if maxlen is not None:
assert maxlen &gt; 0
self._head = 0
self._tail = 0
self._maxlen = maxlen
self._capacity = 8 if maxlen is None else maxlen + 1
self._data = [None] * self._capacity # type: ignore
if iterable is not None:
self.extend(iterable)
@property
def maxlen(self) -&gt; int | None:
return self._maxlen
def __resize_2x(self):
backup = list(self)
self._capacity *= 2
self._head = 0
self._tail = len(backup)
self._data.clear()
self._data.extend(backup)
self._data.extend([None] * (self._capacity - len(backup)))
def append(self, x: T):
if (self._tail + 1) % self._capacity == self._head:
if self._maxlen is None:
self.__resize_2x()
else:
self.popleft()
self._data[self._tail] = x
self._tail = (self._tail + 1) % self._capacity
def appendleft(self, x: T):
if (self._tail + 1) % self._capacity == self._head:
if self._maxlen is None:
self.__resize_2x()
else:
self.pop()
self._head = (self._head - 1) % self._capacity
self._data[self._head] = x
def copy(self):
return deque(self, maxlen=self.maxlen)
def count(self, x: T) -&gt; int:
n = 0
for item in self:
if item == x:
n += 1
return n
def extend(self, iterable: Iterable[T]):
for x in iterable:
self.append(x)
def extendleft(self, iterable: Iterable[T]):
for x in iterable:
self.appendleft(x)
def pop(self) -&gt; T:
if self._head == self._tail:
raise IndexError(&quot;pop from an empty deque&quot;)
self._tail = (self._tail - 1) % self._capacity
x = self._data[self._tail]
self._data[self._tail] = None
return x
def popleft(self) -&gt; T:
if self._head == self._tail:
raise IndexError(&quot;pop from an empty deque&quot;)
x = self._data[self._head]
self._data[self._head] = None
self._head = (self._head + 1) % self._capacity
return x
def clear(self):
i = self._head
while i != self._tail:
self._data[i] = None # type: ignore
i = (i + 1) % self._capacity
self._head = 0
self._tail = 0
def rotate(self, n: int = 1):
if len(self) == 0:
return
if n &gt; 0:
n = n % len(self)
for _ in range(n):
self.appendleft(self.pop())
elif n &lt; 0:
n = -n % len(self)
for _ in range(n):
self.append(self.popleft())
def __len__(self) -&gt; int:
return (self._tail - self._head) % self._capacity
def __contains__(self, x: object) -&gt; bool:
for item in self:
if item == x:
return True
return False
def __iter__(self):
i = self._head
while i != self._tail:
yield self._data[i]
i = (i + 1) % self._capacity
def __eq__(self, other: object) -&gt; bool:
if not isinstance(other, deque):
return NotImplemented
if len(self) != len(other):
return False
for x, y in zip(self, other):
if x != y:
return False
return True
def __ne__(self, other: object) -&gt; bool:
if not isinstance(other, deque):
return NotImplemented
return not self == other
def __repr__(self) -&gt; str:
if self.maxlen is None:
return f&quot;deque({list(self)!r})&quot;
return f&quot;deque({list(self)!r}, maxlen={self.maxlen})&quot;
</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/cmath/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">cmath</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/colorcvt/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">colorcvt</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "collections", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

357
modules/colorcvt/index.html Normal file
View File

@ -0,0 +1,357 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>colorcvt | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="colorcvt | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Provide color conversion functions.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/colorcvt/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/colorcvt/">
<meta property="og:title" content="colorcvt | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Provide color conversion functions.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/colorcvt/">
<meta property="twitter:title" content="colorcvt | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Provide color conversion functions.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="colorcvt" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#colorcvt">#</doc-anchor-trigger>
<span>colorcvt</span>
</h1>
</doc-anchor-target>
<p>Provide color conversion functions.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from vmath import vec3
def linear_srgb_to_srgb(rgb: vec3) -&gt; vec3: ...
def srgb_to_linear_srgb(rgb: vec3) -&gt; vec3: ...
def srgb_to_hsv(rgb: vec3) -&gt; vec3: ...
def hsv_to_srgb(hsv: vec3) -&gt; vec3: ...
def oklch_to_linear_srgb(lch: vec3) -&gt; vec3: ...
def linear_srgb_to_oklch(rgb: vec3) -&gt; vec3: ...</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/collections/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">collections</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/cute_png/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">cute_png</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "colorcvt", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

371
modules/cute_png/index.html Normal file
View File

@ -0,0 +1,371 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>cute_png | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="cute_png | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="This module is optional. Set option PK_BUILD_MODULE_CUTE_PNG to ON in your CMakeLists.txt to enable it.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/cute_png/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/cute_png/">
<meta property="og:title" content="cute_png | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="This module is optional. Set option PK_BUILD_MODULE_CUTE_PNG to ON in your CMakeLists.txt to enable it.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/cute_png/">
<meta property="twitter:title" content="cute_png | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="This module is optional. Set option PK_BUILD_MODULE_CUTE_PNG to ON in your CMakeLists.txt to enable it.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="cute_png" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#cute_png">#</doc-anchor-trigger>
<span>cute_png</span>
</h1>
</doc-anchor-target>
<div class="flex mb-6">
<div class="shrink-0 w-1.5 rounded-tl-lg rounded-bl-lg bg-callout-primary"></div>
<div class="flex w-full py-4 border border-l-0 rounded-tr-lg rounded-br-lg doc-callout bg-callout-base-bg border-callout-base-border" role="alert">
<div class="flex items-center ml-4 h-7">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px text-callout-primary" width="22" height="22" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor"><g>
<path d="M12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9z"></path>
<path d="M12 11c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zM12.01 7c-.56 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path>
<path fill="none" d="M0 0h24v24H0z"></path>
</g></g>
</svg>
</div>
<div class="pr-5 ml-3 w-full">
<p>This module is optional. Set option <code v-pre>PK_BUILD_MODULE_CUTE_PNG</code> to <code v-pre>ON</code> in your <code v-pre>CMakeLists.txt</code> to enable it.</p>
</div>
</div>
</div>
<p>Wraps <a href="https://github.com/RandyGaul/cute_headers/blob/master/cute_png.h">cute_png.h</a> for PNG image loading and saving.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from array2d import array2d
from vmath import color32
def loads(data: bytes) -&gt; array2d[color32]: ...
def dumps(image: array2d[color32]) -&gt; bytes: ...</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/colorcvt/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">colorcvt</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/dataclasses/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">dataclasses</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "cute_png", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,437 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>dataclasses | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="dataclasses | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="A decorator that is used to add special method to classes, including __init__, __repr__ and __eq__.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/dataclasses/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/dataclasses/">
<meta property="og:title" content="dataclasses | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="A decorator that is used to add special method to classes, including __init__, __repr__ and __eq__.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/dataclasses/">
<meta property="twitter:title" content="dataclasses | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="A decorator that is used to add special method to classes, including __init__, __repr__ and __eq__.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="dataclasses" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#dataclasses">#</doc-anchor-trigger>
<span>dataclasses</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="dataclassesdataclass">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#dataclassesdataclass">#</doc-anchor-trigger>
<span><code v-pre>dataclasses.dataclass</code></span>
</h3>
</doc-anchor-target>
<p>A decorator that is used to add special method to classes, including <code v-pre>__init__</code>, <code v-pre>__repr__</code> and <code v-pre>__eq__</code>.</p>
<doc-anchor-target id="dataclassesasdictobj---dict">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#dataclassesasdictobj---dict">#</doc-anchor-trigger>
<span><code v-pre>dataclasses.asdict(obj) -&gt; dict</code></span>
</h3>
</doc-anchor-target>
<p>Convert a dataclass instance to a dictionary.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">def _get_annotations(cls: type):
inherits = []
while cls is not object:
inherits.append(cls)
cls = cls.__base__
inherits.reverse()
res = {}
for cls in inherits:
res.update(cls.__annotations__)
return res.keys()
def _wrapped__init__(self, *args, **kwargs):
cls = type(self)
cls_d = cls.__dict__
fields = _get_annotations(cls)
i = 0 # index into args
for field in fields:
if field in kwargs:
setattr(self, field, kwargs.pop(field))
else:
if i &lt; len(args):
setattr(self, field, args[i])
i += 1
elif field in cls_d: # has default value
setattr(self, field, cls_d[field])
else:
raise TypeError(f&quot;{cls.__name__} missing required argument {field!r}&quot;)
if len(args) &gt; i:
raise TypeError(f&quot;{cls.__name__} takes {len(fields)} positional arguments but {len(args)} were given&quot;)
if len(kwargs) &gt; 0:
raise TypeError(f&quot;{cls.__name__} got an unexpected keyword argument {next(iter(kwargs))!r}&quot;)
def _wrapped__repr__(self):
fields = _get_annotations(type(self))
obj_d = self.__dict__
args: list = [f&quot;{field}={obj_d[field]!r}&quot; for field in fields]
return f&quot;{type(self).__name__}({', '.join(args)})&quot;
def _wrapped__eq__(self, other):
if type(self) is not type(other):
return False
fields = _get_annotations(type(self))
for field in fields:
if getattr(self, field) != getattr(other, field):
return False
return True
def _wrapped__ne__(self, other):
return not self.__eq__(other)
def dataclass(cls: type):
assert type(cls) is type
cls_d = cls.__dict__
if '__init__' not in cls_d:
cls.__init__ = _wrapped__init__
if '__repr__' not in cls_d:
cls.__repr__ = _wrapped__repr__
if '__eq__' not in cls_d:
cls.__eq__ = _wrapped__eq__
if '__ne__' not in cls_d:
cls.__ne__ = _wrapped__ne__
fields = _get_annotations(cls)
has_default = False
for field in fields:
if field in cls_d:
has_default = True
else:
if has_default:
raise TypeError(f&quot;non-default argument {field!r} follows default argument&quot;)
return cls
def asdict(obj) -&gt; dict:
fields = _get_annotations(type(obj))
obj_d = obj.__dict__
return {field: obj_d[field] for field in fields}</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/cute_png/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">cute_png</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/datetime/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">datetime</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "dataclasses", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

494
modules/datetime/index.html Normal file
View File

@ -0,0 +1,494 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>datetime | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="datetime | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Returns the current date and time as a datetime object.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/datetime/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/datetime/">
<meta property="og:title" content="datetime | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Returns the current date and time as a datetime object.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/datetime/">
<meta property="twitter:title" content="datetime | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Returns the current date and time as a datetime object.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="datetime" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#datetime">#</doc-anchor-trigger>
<span>datetime</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="datetimenow">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#datetimenow">#</doc-anchor-trigger>
<span><code v-pre>datetime.now()</code></span>
</h3>
</doc-anchor-target>
<p>Returns the current date and time as a <code v-pre>datetime</code> object.</p>
<doc-anchor-target id="datetoday">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#datetoday">#</doc-anchor-trigger>
<span><code v-pre>date.today()</code></span>
</h3>
</doc-anchor-target>
<p>Returns the current local date as a <code v-pre>date</code> object.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from time import localtime
import operator
class timedelta:
def __init__(self, days=0, seconds=0):
self.days = days
self.seconds = seconds
def __repr__(self):
return f&quot;datetime.timedelta(days={self.days}, seconds={self.seconds})&quot;
def __eq__(self, other) -&gt; bool:
if not isinstance(other, timedelta):
return NotImplemented
return (self.days, self.seconds) == (other.days, other.seconds)
def __ne__(self, other) -&gt; bool:
if not isinstance(other, timedelta):
return NotImplemented
return (self.days, self.seconds) != (other.days, other.seconds)
class date:
def __init__(self, year: int, month: int, day: int):
self.year = year
self.month = month
self.day = day
@staticmethod
def today():
t = localtime()
return date(t.tm_year, t.tm_mon, t.tm_mday)
def __cmp(self, other, op):
if not isinstance(other, date):
return NotImplemented
if self.year != other.year:
return op(self.year, other.year)
if self.month != other.month:
return op(self.month, other.month)
return op(self.day, other.day)
def __eq__(self, other) -&gt; bool:
return self.__cmp(other, operator.eq)
def __ne__(self, other) -&gt; bool:
return self.__cmp(other, operator.ne)
def __lt__(self, other: 'date') -&gt; bool:
return self.__cmp(other, operator.lt)
def __le__(self, other: 'date') -&gt; bool:
return self.__cmp(other, operator.le)
def __gt__(self, other: 'date') -&gt; bool:
return self.__cmp(other, operator.gt)
def __ge__(self, other: 'date') -&gt; bool:
return self.__cmp(other, operator.ge)
def __str__(self):
return f&quot;{self.year}-{self.month:02}-{self.day:02}&quot;
def __repr__(self):
return f&quot;datetime.date({self.year}, {self.month}, {self.day})&quot;
class datetime(date):
def __init__(self, year: int, month: int, day: int, hour: int, minute: int, second: int):
super().__init__(year, month, day)
# Validate and set hour, minute, and second
if not 0 &lt;= hour &lt;= 23:
raise ValueError(&quot;Hour must be between 0 and 23&quot;)
self.hour = hour
if not 0 &lt;= minute &lt;= 59:
raise ValueError(&quot;Minute must be between 0 and 59&quot;)
self.minute = minute
if not 0 &lt;= second &lt;= 59:
raise ValueError(&quot;Second must be between 0 and 59&quot;)
self.second = second
def date(self) -&gt; date:
return date(self.year, self.month, self.day)
@staticmethod
def now():
t = localtime()
tm_sec = t.tm_sec
if tm_sec == 60:
tm_sec = 59
return datetime(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, tm_sec)
def __str__(self):
return f&quot;{self.year}-{self.month:02}-{self.day:02} {self.hour:02}:{self.minute:02}:{self.second:02}&quot;
def __repr__(self):
return f&quot;datetime.datetime({self.year}, {self.month}, {self.day}, {self.hour}, {self.minute}, {self.second})&quot;
def __cmp(self, other, op):
if not isinstance(other, datetime):
return NotImplemented
if self.year != other.year:
return op(self.year, other.year)
if self.month != other.month:
return op(self.month, other.month)
if self.day != other.day:
return op(self.day, other.day)
if self.hour != other.hour:
return op(self.hour, other.hour)
if self.minute != other.minute:
return op(self.minute, other.minute)
return op(self.second, other.second)
def __eq__(self, other) -&gt; bool:
return self.__cmp(other, operator.eq)
def __ne__(self, other) -&gt; bool:
return self.__cmp(other, operator.ne)
def __lt__(self, other) -&gt; bool:
return self.__cmp(other, operator.lt)
def __le__(self, other) -&gt; bool:
return self.__cmp(other, operator.le)
def __gt__(self, other) -&gt; bool:
return self.__cmp(other, operator.gt)
def __ge__(self, other) -&gt; bool:
return self.__cmp(other, operator.ge)
</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/dataclasses/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">dataclasses</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/easing/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">easing</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "datetime", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

373
modules/easing/index.html Normal file
View File

@ -0,0 +1,373 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>easing | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="easing | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Python wrapper for easing functions.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/easing/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/easing/">
<meta property="og:title" content="easing | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Python wrapper for easing functions.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/easing/">
<meta property="twitter:title" content="easing | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Python wrapper for easing functions.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="easing" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#easing">#</doc-anchor-trigger>
<span>easing</span>
</h1>
</doc-anchor-target>
<p>Python wrapper for <a href="https://easings.net/">easing functions</a>.</p>
<ul>
<li><code v-pre>easing.Linear(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InSine(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutSine(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutSine(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InQuad(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutQuad(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutQuad(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InCubic(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutCubic(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutCubic(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InQuart(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutQuart(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutQuart(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InQuint(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutQuint(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutQuint(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InExpo(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutExpo(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutExpo(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InCirc(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutCirc(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutCirc(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InBack(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutBack(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutBack(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InElastic(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutElastic(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutElastic(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InBounce(t: float) -&gt; float</code></li>
<li><code v-pre>easing.OutBounce(t: float) -&gt; float</code></li>
<li><code v-pre>easing.InOutBounce(t: float) -&gt; float</code></li>
</ul>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/datetime/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">datetime</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/enum/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">enum</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "easing", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

360
modules/enum/index.html Normal file
View File

@ -0,0 +1,360 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>enum | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="enum | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Base class for creating enumerated constants.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/enum/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/enum/">
<meta property="og:title" content="enum | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Base class for creating enumerated constants.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/enum/">
<meta property="twitter:title" content="enum | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Base class for creating enumerated constants.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="enum" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#enum">#</doc-anchor-trigger>
<span>enum</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="enumenum">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#enumenum">#</doc-anchor-trigger>
<span><code v-pre>enum.Enum</code></span>
</h3>
</doc-anchor-target>
<p>Base class for creating enumerated constants.</p>
<p>Example:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from enum import Enum
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
print(Color.RED) # Color.RED
print(Color.RED.name) # 'RED'
print(Color.RED.value) # 1</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/easing/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">easing</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/functools/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">functools</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "enum", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,431 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>functools | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="functools | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="A decorator that caches a function's return value each time it is called.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/functools/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/functools/">
<meta property="og:title" content="functools | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="A decorator that caches a function's return value each time it is called.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/functools/">
<meta property="twitter:title" content="functools | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="A decorator that caches a function's return value each time it is called.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="functools" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#functools">#</doc-anchor-trigger>
<span>functools</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="functoolscache">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#functoolscache">#</doc-anchor-trigger>
<span><code v-pre>functools.cache</code></span>
</h3>
</doc-anchor-target>
<p>A decorator that caches a function&#x27;s return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated.</p>
<doc-anchor-target id="functoolslru_cachemaxsize128">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#functoolslru_cachemaxsize128">#</doc-anchor-trigger>
<span><code v-pre>functools.lru_cache(maxsize=128)</code></span>
</h3>
</doc-anchor-target>
<p>A decorator that wraps a function with a memoizing callable that saves up to the maxsize most recent calls.</p>
<doc-anchor-target id="functoolsreducefunction-sequence-initial">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#functoolsreducefunction-sequence-initial">#</doc-anchor-trigger>
<span><code v-pre>functools.reduce(function, sequence, initial=...)</code></span>
</h3>
</doc-anchor-target>
<p>Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, <code v-pre>functools.reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])</code> calculates <code v-pre>((((1+2)+3)+4)+5)</code>. The left argument, <code v-pre>x</code>, is the accumulated value and the right argument, <code v-pre>y</code>, is the update value from the sequence. If the optional <code v-pre>initial</code> is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.</p>
<doc-anchor-target id="functoolspartialf-args-kwargs">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#functoolspartialf-args-kwargs">#</doc-anchor-trigger>
<span><code v-pre>functools.partial(f, *args, **kwargs)</code></span>
</h3>
</doc-anchor-target>
<p>Return a new partial object which when called will behave like <code v-pre>f</code> called with the positional arguments <code v-pre>args</code> and keyword arguments <code v-pre>kwargs</code>. If more arguments are supplied to the call, they are appended to <code v-pre>args</code>. If additional keyword arguments are supplied, they extend and override <code v-pre>kwargs</code>.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">class cache:
def __init__(self, f):
self.f = f
self.cache = {}
def __call__(self, *args):
if args not in self.cache:
self.cache[args] = self.f(*args)
return self.cache[args]
class lru_cache:
def __init__(self, maxsize=128):
self.maxsize = maxsize
self.cache = {}
def __call__(self, f):
def wrapped(*args):
if args in self.cache:
res = self.cache.pop(args)
self.cache[args] = res
return res
res = f(*args)
if len(self.cache) &gt;= self.maxsize:
first_key = next(iter(self.cache))
self.cache.pop(first_key)
self.cache[args] = res
return res
return wrapped
def reduce(function, sequence, initial=...):
it = iter(sequence)
if initial is ...:
try:
value = next(it)
except StopIteration:
raise TypeError(&quot;reduce() of empty sequence with no initial value&quot;)
else:
value = initial
for element in it:
value = function(value, element)
return value
class partial:
def __init__(self, f, *args, **kwargs):
self.f = f
if not callable(f):
raise TypeError(&quot;the first argument must be callable&quot;)
self.args = args
self.kwargs = kwargs
def __call__(self, *args, **kwargs):
kwargs.update(self.kwargs)
return self.f(*self.args, *args, **kwargs)
</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/enum/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">enum</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/gc/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">gc</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "functools", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

367
modules/gc/index.html Normal file
View File

@ -0,0 +1,367 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>gc | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="gc | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Invoke the garbage collector.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/gc/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/gc/">
<meta property="og:title" content="gc | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Invoke the garbage collector.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/gc/">
<meta property="twitter:title" content="gc | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Invoke the garbage collector.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="gc" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#gc">#</doc-anchor-trigger>
<span>gc</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="gccollect">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#gccollect">#</doc-anchor-trigger>
<span><code v-pre>gc.collect()</code></span>
</h3>
</doc-anchor-target>
<p>Invoke the garbage collector.</p>
<doc-anchor-target id="gcenable">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#gcenable">#</doc-anchor-trigger>
<span><code v-pre>gc.enable()</code></span>
</h3>
</doc-anchor-target>
<p>Enable automatic garbage collection.</p>
<doc-anchor-target id="gcdisable">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#gcdisable">#</doc-anchor-trigger>
<span><code v-pre>gc.disable()</code></span>
</h3>
</doc-anchor-target>
<p>Disable automatic garbage collection.</p>
<doc-anchor-target id="gcisenabled">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#gcisenabled">#</doc-anchor-trigger>
<span><code v-pre>gc.isenabled()</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>True</code> if automatic garbage collection is enabled, <code v-pre>False</code> otherwise.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/functools/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">functools</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/heapq/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">heapq</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "gc", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

469
modules/heapq/index.html Normal file
View File

@ -0,0 +1,469 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>heapq | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="heapq | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Push the value item onto the heap, maintaining the heap invariant.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/heapq/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/heapq/">
<meta property="og:title" content="heapq | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Push the value item onto the heap, maintaining the heap invariant.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/heapq/">
<meta property="twitter:title" content="heapq | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Push the value item onto the heap, maintaining the heap invariant.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="heapq" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#heapq">#</doc-anchor-trigger>
<span>heapq</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="heapqheappushheap-item">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#heapqheappushheap-item">#</doc-anchor-trigger>
<span><code v-pre>heapq.heappush(heap, item)</code></span>
</h3>
</doc-anchor-target>
<p>Push the value <code v-pre>item</code> onto the heap, maintaining the heap invariant.</p>
<doc-anchor-target id="heapqheappopheap">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#heapqheappopheap">#</doc-anchor-trigger>
<span><code v-pre>heapq.heappop(heap)</code></span>
</h3>
</doc-anchor-target>
<p>Pop and return the smallest item from the heap, maintaining the heap invariant. If the heap is empty, IndexError is raised. To access the smallest item without popping it, use <code v-pre>heap[0]</code>.</p>
<doc-anchor-target id="heapqheapifyx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#heapqheapifyx">#</doc-anchor-trigger>
<span><code v-pre>heapq.heapify(x)</code></span>
</h3>
</doc-anchor-target>
<p>Transform list <code v-pre>x</code> into a heap, in-place, in linear time.</p>
<doc-anchor-target id="heapqheappushpopheap-item">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#heapqheappushpopheap-item">#</doc-anchor-trigger>
<span><code v-pre>heapq.heappushpop(heap, item)</code></span>
</h3>
</doc-anchor-target>
<p>Push <code v-pre>item</code> on the heap, then pop and return the smallest item from the heap. The combined action runs more efficiently than <code v-pre>heappush()</code> followed by a separate <code v-pre>heappop()</code>.</p>
<doc-anchor-target id="heapqheapreplaceheap-item">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#heapqheapreplaceheap-item">#</doc-anchor-trigger>
<span><code v-pre>heapq.heapreplace(heap, item)</code></span>
</h3>
</doc-anchor-target>
<p>Pop and return the smallest item from the heap, and also push the new item. The heap size doesnt change. If the heap is empty, IndexError is raised.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python"># Heap queue algorithm (a.k.a. priority queue)
def heappush(heap, item):
&quot;&quot;&quot;Push item onto heap, maintaining the heap invariant.&quot;&quot;&quot;
heap.append(item)
_siftdown(heap, 0, len(heap)-1)
def heappop(heap):
&quot;&quot;&quot;Pop the smallest item off the heap, maintaining the heap invariant.&quot;&quot;&quot;
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
return returnitem
return lastelt
def heapreplace(heap, item):
&quot;&quot;&quot;Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable uses of
this routine unless written as part of a conditional replacement:
if item &gt; heap[0]:
item = heapreplace(heap, item)
&quot;&quot;&quot;
returnitem = heap[0] # raises appropriate IndexError if heap is empty
heap[0] = item
_siftup(heap, 0)
return returnitem
def heappushpop(heap, item):
&quot;&quot;&quot;Fast version of a heappush followed by a heappop.&quot;&quot;&quot;
if heap and heap[0] &lt; item:
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item
def heapify(x):
&quot;&quot;&quot;Transform list into a heap, in-place, in O(len(x)) time.&quot;&quot;&quot;
n = len(x)
# Transform bottom-up. The largest index there's any point to looking at
# is the largest with a child index in-range, so must have 2*i + 1 &lt; n,
# or i &lt; (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2 so
# j-1 is the largest, which is n//2 - 1. If n is odd = 2*j+1, this is
# (2*j+1-1)/2 = j so j-1 is the largest, and that's again n//2-1.
for i in reversed(range(n//2)):
_siftup(x, i)
# 'heap' is a heap at all indices &gt;= startpos, except possibly for pos. pos
# is the index of a leaf with a possibly out-of-order value. Restore the
# heap invariant.
def _siftdown(heap, startpos, pos):
newitem = heap[pos]
# Follow the path to the root, moving parents down until finding a place
# newitem fits.
while pos &gt; startpos:
parentpos = (pos - 1) &gt;&gt; 1
parent = heap[parentpos]
if newitem &lt; parent:
heap[pos] = parent
pos = parentpos
continue
break
heap[pos] = newitem
def _siftup(heap, pos):
endpos = len(heap)
startpos = pos
newitem = heap[pos]
# Bubble up the smaller child until hitting a leaf.
childpos = 2*pos + 1 # leftmost child position
while childpos &lt; endpos:
# Set childpos to index of smaller child.
rightpos = childpos + 1
if rightpos &lt; endpos and not heap[childpos] &lt; heap[rightpos]:
childpos = rightpos
# Move the smaller child up.
heap[pos] = heap[childpos]
pos = childpos
childpos = 2*pos + 1
# The leaf at pos is empty now. Put newitem there, and bubble it up
# to its final resting place (by sifting its parents down).
heap[pos] = newitem
_siftdown(heap, startpos, pos)</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/gc/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">gc</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/importlib/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">importlib</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "heapq", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,346 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>importlib | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="importlib | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/importlib/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/importlib/">
<meta property="og:title" content="importlib | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/importlib/">
<meta property="twitter:title" content="importlib | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="importlib" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#importlib">#</doc-anchor-trigger>
<span>importlib</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="importlibreloadmodule">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#importlibreloadmodule">#</doc-anchor-trigger>
<span><code v-pre>importlib.reload(module)</code></span>
</h3>
</doc-anchor-target>
<p>Reload a previously imported module. The argument must be a module object, so it must have been successfully imported before. This is useful if you have edited the module source file using an external editor and want to try out the new version without leaving the Python interpreter. The return value is the module object (the same as the argument).</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/heapq/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">heapq</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/json/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">json</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "importlib", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

353
modules/json/index.html Normal file
View File

@ -0,0 +1,353 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>json | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="json | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Decode a JSON string into a python object.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/json/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/json/">
<meta property="og:title" content="json | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Decode a JSON string into a python object.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/json/">
<meta property="twitter:title" content="json | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Decode a JSON string into a python object.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="json" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#json">#</doc-anchor-trigger>
<span>json</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="jsonloadsdata-str">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#jsonloadsdata-str">#</doc-anchor-trigger>
<span><code v-pre>json.loads(data: str)</code></span>
</h3>
</doc-anchor-target>
<p>Decode a JSON string into a python object.</p>
<doc-anchor-target id="jsondumpsobj-indent0---str">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#jsondumpsobj-indent0---str">#</doc-anchor-trigger>
<span><code v-pre>json.dumps(obj, indent=0) -&gt; str</code></span>
</h3>
</doc-anchor-target>
<p>Encode a python object into a JSON string.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/importlib/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">importlib</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/libhv/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">libhv</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "json", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

486
modules/libhv/index.html Normal file
View File

@ -0,0 +1,486 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>libhv | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="libhv | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="This module is optional. Set option PK_BUILD_MODULE_LIBHV to ON in your CMakeLists.txt to enable it.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/libhv/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/libhv/">
<meta property="og:title" content="libhv | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="This module is optional. Set option PK_BUILD_MODULE_LIBHV to ON in your CMakeLists.txt to enable it.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/libhv/">
<meta property="twitter:title" content="libhv | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="This module is optional. Set option PK_BUILD_MODULE_LIBHV to ON in your CMakeLists.txt to enable it.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="libhv" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#libhv">#</doc-anchor-trigger>
<span>libhv</span>
</h1>
</doc-anchor-target>
<div class="flex mb-6">
<div class="shrink-0 w-1.5 rounded-tl-lg rounded-bl-lg bg-callout-primary"></div>
<div class="flex w-full py-4 border border-l-0 rounded-tr-lg rounded-br-lg doc-callout bg-callout-base-bg border-callout-base-border" role="alert">
<div class="flex items-center ml-4 h-7">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px text-callout-primary" width="22" height="22" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor"><g>
<path d="M12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9z"></path>
<path d="M12 11c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zM12.01 7c-.56 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path>
<path fill="none" d="M0 0h24v24H0z"></path>
</g></g>
</svg>
</div>
<div class="pr-5 ml-3 w-full">
<p>This module is optional. Set option <code v-pre>PK_BUILD_MODULE_LIBHV</code> to <code v-pre>ON</code> in your <code v-pre>CMakeLists.txt</code> to enable it.</p>
</div>
</div>
</div>
<p><code v-pre>libhv</code> is a git submodule located at <code v-pre>3rd/libhv/libhv</code>. If you cannot find it, please run the following command to initialize the submodule:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-bash"><code v-pre class="language-bash">git submodule update --init --recursive</code></pre>
</doc-codeblock></div>
<p>Simple bindings for <a href="https://github.com/ithewei/libhv">libhv</a>, which provides cross platform implementation of the following:</p>
<ul>
<li>HTTP server</li>
<li>HTTP client</li>
<li>WebSocket server</li>
<li>WebSocket client</li>
</ul>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from typing import Literal, Generator, Callable, Union
WsChannelId = int
HttpStatusCode = int
HttpHeaders = dict[str, str]
ErrorCode = int
class Future[T]:
@property
def completed(self) -&gt; bool: ...
def cancel(self) -&gt; None: ...
def __iter__(self) -&gt; Generator[T, None, None]: ...
class HttpResponse(Future['HttpResponse']):
@property
def status_code(self) -&gt; int: ...
@property
def headers(self) -&gt; dict[str, str]: ...
@property
def text(self) -&gt; str: ...
@property
def content(self) -&gt; bytes: ...
def json(self): ...
class HttpClient:
def get(self, url: str, /, params=None, headers=None, timeout=10) -&gt; HttpResponse: ...
def post(self, url: str, /, params=None, headers=None, data=None, json=None, timeout=10) -&gt; HttpResponse: ...
def put(self, url: str, /, params=None, headers=None, data=None, json=None, timeout=10) -&gt; HttpResponse: ...
def delete(self, url: str, /, params=None, headers=None, timeout=10) -&gt; HttpResponse: ...
class HttpRequest:
@property
def method(self) -&gt; Literal['GET', 'POST', 'PUT', 'DELETE']: ...
@property
def path(self) -&gt; str: ...
@property
def url(self) -&gt; str: ...
@property
def headers(self) -&gt; HttpHeaders: ...
@property
def data(self) -&gt; str | bytes: ...
class HttpServer:
def __init__(self, host: str, port: int, /) -&gt; None: ...
def start(self) -&gt; ErrorCode: ...
def stop(self) -&gt; ErrorCode: ...
def dispatch[T](self, fn: Callable[
[HttpRequest],
T | tuple[T, HttpStatusCode] | tuple[T, HttpStatusCode, HttpHeaders]
], /) -&gt; bool:
&quot;&quot;&quot;Dispatch one HTTP request through `fn`. `fn` should return one of the following:
+ object
+ (object, status_code)
+ (object, status_code, headers)
Return `True` if dispatched, otherwise `False`.
&quot;&quot;&quot;
def ws_set_ping_interval(self, milliseconds: int, /) -&gt; None:
&quot;&quot;&quot;Set WebSocket ping interval in milliseconds.&quot;&quot;&quot;
def ws_close(self, channel: WsChannelId, /) -&gt; ErrorCode:
&quot;&quot;&quot;Close WebSocket channel.&quot;&quot;&quot;
def ws_send(self, channel: WsChannelId, data: str, /) -&gt; int:
&quot;&quot;&quot;Send WebSocket message through `channel`.&quot;&quot;&quot;
def ws_recv(self) -&gt; Union[
tuple[Literal['onopen'], tuple[WsChannelId, HttpRequest]],
tuple[Literal['onmessage'], tuple[WsChannelId, str]],
tuple[Literal['onclose'], WsChannelId],
None
]:
&quot;&quot;&quot;Receive one WebSocket message.
Return one of the following or `None` if nothing to receive.
+ `&quot;onopen&quot;`: (channel, request)
+ `&quot;onclose&quot;`: channel
+ `&quot;onmessage&quot;`: (channel, body)
&quot;&quot;&quot;
class WebSocketClient:
def open(self, url: str, headers=None, /) -&gt; ErrorCode: ...
def close(self) -&gt; ErrorCode: ...
def send(self, data: str, /) -&gt; int:
&quot;&quot;&quot;Send WebSocket message.&quot;&quot;&quot;
def recv(self) -&gt; Union[
tuple[Literal['onopen'], None],
tuple[Literal['onclose'], None],
tuple[Literal['onmessage'], str],
None
]:
&quot;&quot;&quot;Receive one WebSocket message.
Return one of the following or `None` if nothing to receive.
+ `&quot;onopen&quot;`: `None`
+ `&quot;onclose&quot;`: `None`
+ `&quot;onmessage&quot;`: body
&quot;&quot;&quot;
def strerror(errno: ErrorCode, /) -&gt; str:
&quot;&quot;&quot;Get error message by errno via `hv_strerror`.&quot;&quot;&quot;
</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/json/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">json</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/lz4/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">lz4</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "libhv", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

377
modules/lz4/index.html Normal file
View File

@ -0,0 +1,377 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>lz4 | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="lz4 | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="This module is optional. Set option PK_BUILD_MODULE_LZ4 to ON in your CMakeLists.txt to enable it.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/lz4/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/lz4/">
<meta property="og:title" content="lz4 | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="This module is optional. Set option PK_BUILD_MODULE_LZ4 to ON in your CMakeLists.txt to enable it.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/lz4/">
<meta property="twitter:title" content="lz4 | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="This module is optional. Set option PK_BUILD_MODULE_LZ4 to ON in your CMakeLists.txt to enable it.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="lz4" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#lz4">#</doc-anchor-trigger>
<span>lz4</span>
</h1>
</doc-anchor-target>
<div class="flex mb-6">
<div class="shrink-0 w-1.5 rounded-tl-lg rounded-bl-lg bg-callout-primary"></div>
<div class="flex w-full py-4 border border-l-0 rounded-tr-lg rounded-br-lg doc-callout bg-callout-base-bg border-callout-base-border" role="alert">
<div class="flex items-center ml-4 h-7">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px text-callout-primary" width="22" height="22" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor"><g>
<path d="M12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9z"></path>
<path d="M12 11c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zM12.01 7c-.56 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path>
<path fill="none" d="M0 0h24v24H0z"></path>
</g></g>
</svg>
</div>
<div class="pr-5 ml-3 w-full">
<p>This module is optional. Set option <code v-pre>PK_BUILD_MODULE_LZ4</code> to <code v-pre>ON</code> in your <code v-pre>CMakeLists.txt</code> to enable it.</p>
</div>
</div>
</div>
<p>LZ4 compression and decompression.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">def compress(data: bytes) -&gt; bytes:
&quot;&quot;&quot;Compress the given data into LZ4 block format.
This function is equivalent to `lz4.block.compress` of https://pypi.org/project/lz4/.
&quot;&quot;&quot;
def decompress(data: bytes) -&gt; bytes:
&quot;&quot;&quot;Decompress the given LZ4 block format data produced by `lz4.compress()`.
This function is equivalent to `lz4.block.decompress` of https://pypi.org/project/lz4/.
&quot;&quot;&quot;</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/libhv/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">libhv</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/math/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">math</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "lz4", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

555
modules/math/index.html Normal file
View File

@ -0,0 +1,555 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>math | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="math | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="3.141592653589793">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/math/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/math/">
<meta property="og:title" content="math | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="3.141592653589793">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/math/">
<meta property="twitter:title" content="math | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="3.141592653589793">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="math" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#math">#</doc-anchor-trigger>
<span>math</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="mathpi">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathpi">#</doc-anchor-trigger>
<span><code v-pre>math.pi</code></span>
</h3>
</doc-anchor-target>
<p>3.141592653589793</p>
<doc-anchor-target id="mathe">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathe">#</doc-anchor-trigger>
<span><code v-pre>math.e</code></span>
</h3>
</doc-anchor-target>
<p>2.718281828459045</p>
<doc-anchor-target id="mathinf">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathinf">#</doc-anchor-trigger>
<span><code v-pre>math.inf</code></span>
</h3>
</doc-anchor-target>
<p>The <code v-pre>inf</code>.</p>
<doc-anchor-target id="mathnan">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathnan">#</doc-anchor-trigger>
<span><code v-pre>math.nan</code></span>
</h3>
</doc-anchor-target>
<p>The <code v-pre>nan</code>.</p>
<doc-anchor-target id="mathceilx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathceilx">#</doc-anchor-trigger>
<span><code v-pre>math.ceil(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the ceiling of <code v-pre>x</code> as a float, the smallest integer value greater than or equal to <code v-pre>x</code>.</p>
<doc-anchor-target id="mathfabsx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfabsx">#</doc-anchor-trigger>
<span><code v-pre>math.fabs(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the absolute value of <code v-pre>x</code>.</p>
<doc-anchor-target id="mathfloorx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfloorx">#</doc-anchor-trigger>
<span><code v-pre>math.floor(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the floor of <code v-pre>x</code> as a float, the largest integer value less than or equal to <code v-pre>x</code>.</p>
<doc-anchor-target id="mathfsumiterable">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfsumiterable">#</doc-anchor-trigger>
<span><code v-pre>math.fsum(iterable)</code></span>
</h3>
</doc-anchor-target>
<p>Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">&gt;&gt;&gt; sum([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
0.9999999999999999
&gt;&gt;&gt; fsum([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
1.0</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="mathgcda-b">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathgcda-b">#</doc-anchor-trigger>
<span><code v-pre>math.gcd(a, b)</code></span>
</h3>
</doc-anchor-target>
<p>Return the greatest common divisor of the integers <code v-pre>a</code> and <code v-pre>b</code>.</p>
<doc-anchor-target id="mathisfinitex">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisfinitex">#</doc-anchor-trigger>
<span><code v-pre>math.isfinite(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>True</code> if <code v-pre>x</code> is neither an infinity nor a NaN, and <code v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathisinfx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisinfx">#</doc-anchor-trigger>
<span><code v-pre>math.isinf(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>True</code> if <code v-pre>x</code> is a positive or negative infinity, and <code v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathisnanx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisnanx">#</doc-anchor-trigger>
<span><code v-pre>math.isnan(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>True</code> if <code v-pre>x</code> is a NaN (not a number), and <code v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathisclosea-b">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathisclosea-b">#</doc-anchor-trigger>
<span><code v-pre>math.isclose(a, b)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>True</code> if the values <code v-pre>a</code> and <code v-pre>b</code> are close to each other and <code v-pre>False</code> otherwise.</p>
<doc-anchor-target id="mathexpx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathexpx">#</doc-anchor-trigger>
<span><code v-pre>math.exp(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>e</code> raised to the power of <code v-pre>x</code>.</p>
<doc-anchor-target id="mathlogx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathlogx">#</doc-anchor-trigger>
<span><code v-pre>math.log(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the natural logarithm of <code v-pre>x</code> (to base <code v-pre>e</code>).</p>
<doc-anchor-target id="mathlog2x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathlog2x">#</doc-anchor-trigger>
<span><code v-pre>math.log2(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the base-2 logarithm of <code v-pre>x</code>. This is usually more accurate than <code v-pre>log(x, 2)</code>.</p>
<doc-anchor-target id="mathlog10x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathlog10x">#</doc-anchor-trigger>
<span><code v-pre>math.log10(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the base-10 logarithm of <code v-pre>x</code>. This is usually more accurate than <code v-pre>log(x, 10)</code>.</p>
<doc-anchor-target id="mathpowx-y">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathpowx-y">#</doc-anchor-trigger>
<span><code v-pre>math.pow(x, y)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>x</code> raised to the power <code v-pre>y</code>.</p>
<doc-anchor-target id="mathsqrtx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathsqrtx">#</doc-anchor-trigger>
<span><code v-pre>math.sqrt(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the square root of <code v-pre>x</code>.</p>
<doc-anchor-target id="mathacosx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathacosx">#</doc-anchor-trigger>
<span><code v-pre>math.acos(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the arc cosine of <code v-pre>x</code>, in radians.</p>
<doc-anchor-target id="mathasinx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathasinx">#</doc-anchor-trigger>
<span><code v-pre>math.asin(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the arc sine of <code v-pre>x</code>, in radians.</p>
<doc-anchor-target id="mathatanx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathatanx">#</doc-anchor-trigger>
<span><code v-pre>math.atan(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the arc tangent of <code v-pre>x</code>, in radians.</p>
<doc-anchor-target id="mathatan2y-x">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathatan2y-x">#</doc-anchor-trigger>
<span><code v-pre>math.atan2(y, x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>atan(y / x)</code>, in radians. The result is between <code v-pre>-pi</code> and <code v-pre>pi</code>. The vector in the plane from the origin to point <code v-pre>(x, y)</code> makes this angle with the positive X axis. The point of <code v-pre>atan2()</code> is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle. For example, <code v-pre>atan(1)</code> and <code v-pre>atan2(1, 1)</code> are both <code v-pre>pi/4</code>, but <code v-pre>atan2(-1, -1)</code> is <code v-pre>-3*pi/4</code>.</p>
<doc-anchor-target id="mathcosx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathcosx">#</doc-anchor-trigger>
<span><code v-pre>math.cos(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the cosine of <code v-pre>x</code> radians.</p>
<doc-anchor-target id="mathsinx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathsinx">#</doc-anchor-trigger>
<span><code v-pre>math.sin(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the sine of <code v-pre>x</code> radians.</p>
<doc-anchor-target id="mathtanx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathtanx">#</doc-anchor-trigger>
<span><code v-pre>math.tan(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the tangent of <code v-pre>x</code> radians.</p>
<doc-anchor-target id="mathdegreesx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathdegreesx">#</doc-anchor-trigger>
<span><code v-pre>math.degrees(x)</code></span>
</h3>
</doc-anchor-target>
<p>Convert angle <code v-pre>x</code> from radians to degrees.</p>
<doc-anchor-target id="mathradiansx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathradiansx">#</doc-anchor-trigger>
<span><code v-pre>math.radians(x)</code></span>
</h3>
</doc-anchor-target>
<p>Convert angle <code v-pre>x</code> from degrees to radians.</p>
<doc-anchor-target id="mathmodfx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathmodfx">#</doc-anchor-trigger>
<span><code v-pre>math.modf(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return the fractional and integer parts of <code v-pre>x</code>. Both results carry the sign of <code v-pre>x</code> and are floats.</p>
<doc-anchor-target id="mathfactorialx">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#mathfactorialx">#</doc-anchor-trigger>
<span><code v-pre>math.factorial(x)</code></span>
</h3>
</doc-anchor-target>
<p>Return <code v-pre>x</code> factorial as an integer.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/lz4/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">lz4</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/operator/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">operator</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "math", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

578
modules/operator/index.html Normal file
View File

@ -0,0 +1,578 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>operator | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="operator | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, ">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/operator/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/operator/">
<meta property="og:title" content="operator | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, ">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/operator/">
<meta property="twitter:title" content="operator | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, ">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="operator" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#operator">#</doc-anchor-trigger>
<span>operator</span>
</h1>
</doc-anchor-target>
<p>The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, <code v-pre>operator.add(x, y)</code> is equivalent to the expression <code v-pre>x+y</code>. Many function names are those used for special methods, without the double underscores.</p>
<doc-anchor-target id="mapping-operators-to-functions">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#mapping-operators-to-functions">#</doc-anchor-trigger>
<span>Mapping Operators to Functions</span>
</h2>
</doc-anchor-target>
<div class="table-wrapper scrollbar overflow-hidden">
<table class="comfortable">
<thead>
<tr>
<th>Operation</th>
<th>Syntax</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ordering</td>
<td><code v-pre>a &lt;= b</code></td>
<td><code v-pre>le(a, b)</code></td>
</tr>
<tr>
<td>Ordering</td>
<td><code v-pre>a &lt; b</code></td>
<td><code v-pre>lt(a, b)</code></td>
</tr>
<tr>
<td>Ordering</td>
<td><code v-pre>a &gt;= b</code></td>
<td><code v-pre>ge(a, b)</code></td>
</tr>
<tr>
<td>Ordering</td>
<td><code v-pre>a &gt; b</code></td>
<td><code v-pre>gt(a, b)</code></td>
</tr>
<tr>
<td>Equality</td>
<td><code v-pre>a == b</code></td>
<td><code v-pre>eq(a, b)</code></td>
</tr>
<tr>
<td>Equality</td>
<td><code v-pre>a != b</code></td>
<td><code v-pre>ne(a, b)</code></td>
</tr>
<tr>
<td>Bitwise AND</td>
<td><code v-pre>a &amp; b</code></td>
<td><code v-pre>and_(a, b)</code></td>
</tr>
<tr>
<td>Bitwise OR</td>
<td><code v-pre>a | b</code></td>
<td><code v-pre>or_(a, b)</code></td>
</tr>
<tr>
<td>Bitwise XOR</td>
<td><code v-pre>a ^ b</code></td>
<td><code v-pre>xor(a, b)</code></td>
</tr>
<tr>
<td>Bitwise Inversion</td>
<td><code v-pre>~a</code></td>
<td><code v-pre>invert(a)</code></td>
</tr>
<tr>
<td>Left Shift</td>
<td><code v-pre>a &lt;&lt; b</code></td>
<td><code v-pre>lshift(a, b)</code></td>
</tr>
<tr>
<td>Right Shift</td>
<td><code v-pre>a &gt;&gt; b</code></td>
<td><code v-pre>rshift(a, b)</code></td>
</tr>
<tr>
<td>Identity</td>
<td><code v-pre>a is b</code></td>
<td><code v-pre>is_(a, b)</code></td>
</tr>
<tr>
<td>Identity</td>
<td><code v-pre>a is not b</code></td>
<td><code v-pre>is_not(a, b)</code></td>
</tr>
<tr>
<td>Negation (Logical)</td>
<td><code v-pre>not a</code></td>
<td><code v-pre>not_(a)</code></td>
</tr>
<tr>
<td>Negation (Arithmetic)</td>
<td><code v-pre>-a</code></td>
<td><code v-pre>neg(a)</code></td>
</tr>
<tr>
<td>Truth Test</td>
<td><code v-pre>bool(a)</code></td>
<td><code v-pre>truth(a)</code></td>
</tr>
<tr>
<td>Containment Test</td>
<td><code v-pre>b in a</code></td>
<td><code v-pre>contains(a, b)</code></td>
</tr>
<tr>
<td>Addition</td>
<td><code v-pre>a + b</code></td>
<td><code v-pre>add(a, b)</code></td>
</tr>
<tr>
<td>Subtraction</td>
<td><code v-pre>a - b</code></td>
<td><code v-pre>sub(a, b)</code></td>
</tr>
<tr>
<td>Multiplication</td>
<td><code v-pre>a * b</code></td>
<td><code v-pre>mul(a, b)</code></td>
</tr>
<tr>
<td>Division</td>
<td><code v-pre>a / b</code></td>
<td><code v-pre>truediv(a, b)</code></td>
</tr>
<tr>
<td>Division</td>
<td><code v-pre>a // b</code></td>
<td><code v-pre>floordiv(a, b)</code></td>
</tr>
<tr>
<td>Modulo</td>
<td><code v-pre>a % b</code></td>
<td><code v-pre>mod(a, b)</code></td>
</tr>
<tr>
<td>Exponentiation</td>
<td><code v-pre>a ** b</code></td>
<td><code v-pre>pow(a, b)</code></td>
</tr>
<tr>
<td>Matrix Multiplication</td>
<td><code v-pre>a @ b</code></td>
<td><code v-pre>matmul(a, b)</code></td>
</tr>
<tr>
<td>Indexing</td>
<td><code v-pre>a[b]</code></td>
<td><code v-pre>getitem(a, b)</code></td>
</tr>
<tr>
<td>Index Assignment</td>
<td><code v-pre>a[b] = c</code></td>
<td><code v-pre>setitem(a, b, c)</code></td>
</tr>
<tr>
<td>Index Deletion</td>
<td><code v-pre>del a[b]</code></td>
<td><code v-pre>delitem(a, b)</code></td>
</tr>
</tbody>
</table>
</div>
<doc-anchor-target id="in-place-operators">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#in-place-operators">#</doc-anchor-trigger>
<span>In-place Operators</span>
</h2>
</doc-anchor-target>
<div class="table-wrapper scrollbar overflow-hidden">
<table class="comfortable">
<thead>
<tr>
<th>Operation</th>
<th>Syntax</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td>Addition</td>
<td><code v-pre>a += b</code></td>
<td><code v-pre>iadd(a, b)</code></td>
</tr>
<tr>
<td>Subtraction</td>
<td><code v-pre>a -= b</code></td>
<td><code v-pre>isub(a, b)</code></td>
</tr>
<tr>
<td>Multiplication</td>
<td><code v-pre>a *= b</code></td>
<td><code v-pre>imul(a, b)</code></td>
</tr>
<tr>
<td>Division</td>
<td><code v-pre>a /= b</code></td>
<td><code v-pre>itruediv(a, b)</code></td>
</tr>
<tr>
<td>Division</td>
<td><code v-pre>a //= b</code></td>
<td><code v-pre>ifloordiv(a, b)</code></td>
</tr>
<tr>
<td>Modulo</td>
<td><code v-pre>a %= b</code></td>
<td><code v-pre>imod(a, b)</code></td>
</tr>
<tr>
<td>Bitwise AND</td>
<td><code v-pre>a &amp;= b</code></td>
<td><code v-pre>iand(a, b)</code></td>
</tr>
<tr>
<td>Bitwise OR</td>
<td><code v-pre>a |= b</code></td>
<td><code v-pre>ior(a, b)</code></td>
</tr>
<tr>
<td>Bitwise XOR</td>
<td><code v-pre>a ^= b</code></td>
<td><code v-pre>ixor(a, b)</code></td>
</tr>
<tr>
<td>Left Shift</td>
<td><code v-pre>a &lt;&lt;= b</code></td>
<td><code v-pre>ilshift(a, b)</code></td>
</tr>
<tr>
<td>Right Shift</td>
<td><code v-pre>a &gt;&gt;= b</code></td>
<td><code v-pre>irshift(a, b)</code></td>
</tr>
</tbody>
</table>
</div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/math/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">math</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/pickle/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">pickle</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "operator", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

376
modules/pickle/index.html Normal file
View File

@ -0,0 +1,376 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>pickle | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="pickle | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Return the pickled representation of an object as a bytes object.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/pickle/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/pickle/">
<meta property="og:title" content="pickle | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Return the pickled representation of an object as a bytes object.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/pickle/">
<meta property="twitter:title" content="pickle | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Return the pickled representation of an object as a bytes object.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="pickle" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#pickle">#</doc-anchor-trigger>
<span>pickle</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="pickledumpsobj---bytes">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#pickledumpsobj---bytes">#</doc-anchor-trigger>
<span><code v-pre>pickle.dumps(obj) -&gt; bytes</code></span>
</h3>
</doc-anchor-target>
<p>Return the pickled representation of an object as a bytes object.</p>
<doc-anchor-target id="pickleloadsb-bytes">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#pickleloadsb-bytes">#</doc-anchor-trigger>
<span><code v-pre>pickle.loads(b: bytes)</code></span>
</h3>
</doc-anchor-target>
<p>Return the unpickled object from a bytes object.</p>
<doc-anchor-target id="what-can-be-pickled-and-unpickled">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#what-can-be-pickled-and-unpickled">#</doc-anchor-trigger>
<span>What can be pickled and unpickled?</span>
</h2>
</doc-anchor-target>
<p>The following types can be pickled:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> None, True, and False;</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> integers, floating-point numbers;</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> strings, bytes;</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> tuples, lists, sets, and dictionaries containing only picklable objects;</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> functions (built-in and user-defined) accessible from the top level of a module (using def, not lambda);</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> classes accessible from the top level of a module;</li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> instances of such classes</li>
</ul>
<p>The following magic methods are available:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>__getnewargs__</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>__getstate__</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" /> <code v-pre>__setstate__</code></li>
<li class="task-list-item"><input disabled="disabled" type="checkbox" checked="checked" /> <code v-pre>__reduce__</code></li>
</ul>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/operator/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">operator</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/pkpy/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">pkpy</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "pickle", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

420
modules/pkpy/index.html Normal file
View File

@ -0,0 +1,420 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>pkpy | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="pkpy | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Provide internal access to the pocketpy interpreter.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/pkpy/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/pkpy/">
<meta property="og:title" content="pkpy | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Provide internal access to the pocketpy interpreter.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/pkpy/">
<meta property="twitter:title" content="pkpy | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Provide internal access to the pocketpy interpreter.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="pkpy" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#pkpy">#</doc-anchor-trigger>
<span>pkpy</span>
</h1>
</doc-anchor-target>
<p>Provide internal access to the pocketpy interpreter.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from typing import Self, Literal
from vmath import vec2, vec2i
class TValue[T]:
def __new__(cls, value: T) -&gt; Self: ...
@property
def value(self) -&gt; T: ...
# TValue_int = TValue[int]
# TValue_float = TValue[float]
# TValue_vec2i = TValue[vec2i]
# TValue_vec2 = TValue[vec2]
configmacros: dict[str, int]
def memory_usage() -&gt; str:
&quot;&quot;&quot;Return a summary of the memory usage.&quot;&quot;&quot;
def is_user_defined_type(t: type) -&gt; bool:
&quot;&quot;&quot;Check if a type is user-defined. This means the type was created by executing python `class` statement.&quot;&quot;&quot;
def enable_full_buffering_mode() -&gt; None:
&quot;&quot;&quot;Enable full buffering mode for ASCII drawings.&quot;&quot;&quot;
def currentvm() -&gt; int:
&quot;&quot;&quot;Return the current VM index.&quot;&quot;&quot;
def watchdog_begin(timeout: int):
&quot;&quot;&quot;Begin the watchdog with `timeout` in milliseconds.
`PK_ENABLE_WATCHDOG` must be defined to `1` to use this feature.
You need to call `watchdog_end()` later.
If `timeout` is reached, `TimeoutError` will be raised.
&quot;&quot;&quot;
def watchdog_end() -&gt; None:
&quot;&quot;&quot;End the watchdog after a call to `watchdog_begin()`.&quot;&quot;&quot;
def profiler_begin() -&gt; None: ...
def profiler_end() -&gt; None: ...
def profiler_reset() -&gt; None: ...
def profiler_report() -&gt; dict[str, list[list]]: ...
class ComputeThread:
def __init__(self, vm_index: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]): ...
@property
def is_done(self) -&gt; bool:
&quot;&quot;&quot;Check if the current job is done.&quot;&quot;&quot;
def wait_for_done(self) -&gt; None:
&quot;&quot;&quot;Wait for the current job to finish.&quot;&quot;&quot;
def last_error(self) -&gt; str | None: ...
def last_retval(self): ...
def submit_exec(self, source: str) -&gt; None:
&quot;&quot;&quot;Submit a job to execute some source code.&quot;&quot;&quot;
def submit_eval(self, source: str) -&gt; None:
&quot;&quot;&quot;Submit a job to evaluate some source code.&quot;&quot;&quot;
def submit_call(self, eval_src: str, *args, **kwargs) -&gt; None:
&quot;&quot;&quot;Submit a job to call a function with arguments.&quot;&quot;&quot;
def exec(self, source: str) -&gt; None:
&quot;&quot;&quot;Directly execute some source code.&quot;&quot;&quot;
def eval(self, source: str):
&quot;&quot;&quot;Directly evaluate some source code.&quot;&quot;&quot;</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/pickle/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">pickle</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/random/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">random</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "pkpy", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

388
modules/random/index.html Normal file
View File

@ -0,0 +1,388 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>random | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="random | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Set the random seed.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/random/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/random/">
<meta property="og:title" content="random | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Set the random seed.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/random/">
<meta property="twitter:title" content="random | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Set the random seed.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="random" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#random">#</doc-anchor-trigger>
<span>random</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="randomseeda">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomseeda">#</doc-anchor-trigger>
<span><code v-pre>random.seed(a)</code></span>
</h3>
</doc-anchor-target>
<p>Set the random seed.</p>
<doc-anchor-target id="randomrandom">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomrandom">#</doc-anchor-trigger>
<span><code v-pre>random.random()</code></span>
</h3>
</doc-anchor-target>
<p>Return a random float number in the range [0.0, 1.0).</p>
<doc-anchor-target id="randomrandinta-b">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomrandinta-b">#</doc-anchor-trigger>
<span><code v-pre>random.randint(a, b)</code></span>
</h3>
</doc-anchor-target>
<p>Return a random integer in the range [a, b].</p>
<doc-anchor-target id="randomuniforma-b">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomuniforma-b">#</doc-anchor-trigger>
<span><code v-pre>random.uniform(a, b)</code></span>
</h3>
</doc-anchor-target>
<p>Return a random float number in the range [a, b).</p>
<doc-anchor-target id="randomchoiceseq">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomchoiceseq">#</doc-anchor-trigger>
<span><code v-pre>random.choice(seq)</code></span>
</h3>
</doc-anchor-target>
<p>Return a random element from a sequence.</p>
<doc-anchor-target id="randomshuffleseq">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomshuffleseq">#</doc-anchor-trigger>
<span><code v-pre>random.shuffle(seq)</code></span>
</h3>
</doc-anchor-target>
<p>Shuffle a sequence inplace.</p>
<doc-anchor-target id="randomchoicespopulation-weightsnone-k1">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#randomchoicespopulation-weightsnone-k1">#</doc-anchor-trigger>
<span><code v-pre>random.choices(population, weights=None, k=1)</code></span>
</h3>
</doc-anchor-target>
<p>Return a k sized list of elements chosen from the population with replacement.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/pkpy/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">pkpy</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/sys/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">sys</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "random", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

382
modules/sys/index.html Normal file
View File

@ -0,0 +1,382 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>sys | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="sys | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="The version of pkpy.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/sys/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/sys/">
<meta property="og:title" content="sys | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="The version of pkpy.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/sys/">
<meta property="twitter:title" content="sys | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="The version of pkpy.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="sys" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#sys">#</doc-anchor-trigger>
<span>sys</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="sysversion">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#sysversion">#</doc-anchor-trigger>
<span><code v-pre>sys.version</code></span>
</h3>
</doc-anchor-target>
<p>The version of pkpy.</p>
<doc-anchor-target id="sysplatform">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#sysplatform">#</doc-anchor-trigger>
<span><code v-pre>sys.platform</code></span>
</h3>
</doc-anchor-target>
<p>May be one of:</p>
<ul>
<li><code v-pre>win32</code></li>
<li><code v-pre>linux</code></li>
<li><code v-pre>darwin</code></li>
<li><code v-pre>android</code></li>
<li><code v-pre>ios</code></li>
<li><code v-pre>emscripten</code></li>
</ul>
<doc-anchor-target id="sysargv">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#sysargv">#</doc-anchor-trigger>
<span><code v-pre>sys.argv</code></span>
</h3>
</doc-anchor-target>
<p>The command line arguments. Set by <code v-pre>py_sys_setargv</code>.</p>
<doc-anchor-target id="syssetrecursionlimitlimit-int">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#syssetrecursionlimitlimit-int">#</doc-anchor-trigger>
<span><code v-pre>sys.setrecursionlimit(limit: int)</code></span>
</h3>
</doc-anchor-target>
<p>Set the maximum depth of the Python interpreter stack to <code v-pre>limit</code>. This limit prevents infinite recursion from causing an overflow of the C stack and crashing the interpreter.</p>
<doc-anchor-target id="sysgetrecursionlimit---int">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#sysgetrecursionlimit---int">#</doc-anchor-trigger>
<span><code v-pre>sys.getrecursionlimit() -&gt; int</code></span>
</h3>
</doc-anchor-target>
<p>Return the current value of the recursion limit.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/random/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">random</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/time/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">time</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "sys", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

360
modules/time/index.html Normal file
View File

@ -0,0 +1,360 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>time | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="time | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Returns the current time in seconds since the epoch as a floating point number.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/time/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/time/">
<meta property="og:title" content="time | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Returns the current time in seconds since the epoch as a floating point number.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/time/">
<meta property="twitter:title" content="time | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Returns the current time in seconds since the epoch as a floating point number.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="time" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#time">#</doc-anchor-trigger>
<span>time</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="timetime">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#timetime">#</doc-anchor-trigger>
<span><code v-pre>time.time()</code></span>
</h3>
</doc-anchor-target>
<p>Returns the current time in seconds since the epoch as a floating point number.</p>
<doc-anchor-target id="timesleepsecs">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#timesleepsecs">#</doc-anchor-trigger>
<span><code v-pre>time.sleep(secs)</code></span>
</h3>
</doc-anchor-target>
<p>Suspend execution of the calling thread for the given number of seconds.</p>
<doc-anchor-target id="timelocaltime">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#timelocaltime">#</doc-anchor-trigger>
<span><code v-pre>time.localtime()</code></span>
</h3>
</doc-anchor-target>
<p>Returns the current struct time as a <code v-pre>struct_time</code> object.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/sys/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">sys</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/traceback/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">traceback</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "time", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,353 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>traceback | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="traceback | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Print the last exception and its traceback.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/traceback/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/traceback/">
<meta property="og:title" content="traceback | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Print the last exception and its traceback.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/traceback/">
<meta property="twitter:title" content="traceback | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Print the last exception and its traceback.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="traceback" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#traceback">#</doc-anchor-trigger>
<span>traceback</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="tracebackprint_exc---none">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#tracebackprint_exc---none">#</doc-anchor-trigger>
<span><code v-pre>traceback.print_exc() -&gt; None</code></span>
</h3>
</doc-anchor-target>
<p>Print the last exception and its traceback.</p>
<doc-anchor-target id="tracebackformat_exc---str">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#tracebackformat_exc---str">#</doc-anchor-trigger>
<span><code v-pre>traceback.format_exc() -&gt; str</code></span>
</h3>
</doc-anchor-target>
<p>Return the last exception and its traceback as a string.</p>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/time/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">time</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/typing/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">typing</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "traceback", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

406
modules/typing/index.html Normal file
View File

@ -0,0 +1,406 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>typing | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="typing | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Placeholder module for type hints.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/typing/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/typing/">
<meta property="og:title" content="typing | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Placeholder module for type hints.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/typing/">
<meta property="twitter:title" content="typing | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Placeholder module for type hints.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="typing" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#typing">#</doc-anchor-trigger>
<span>typing</span>
</h1>
</doc-anchor-target>
<p>Placeholder module for type hints.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">class _Placeholder:
def __init__(self, *args, **kwargs):
pass
def __getitem__(self, *args):
return self
def __call__(self, *args, **kwargs):
return self
def __and__(self, other):
return self
def __or__(self, other):
return self
def __xor__(self, other):
return self
_PLACEHOLDER = _Placeholder()
Sequence = _PLACEHOLDER
List = _PLACEHOLDER
Dict = _PLACEHOLDER
Tuple = _PLACEHOLDER
Set = _PLACEHOLDER
Any = _PLACEHOLDER
Union = _PLACEHOLDER
Optional = _PLACEHOLDER
Callable = _PLACEHOLDER
Type = _PLACEHOLDER
TypeAlias = _PLACEHOLDER
NewType = _PLACEHOLDER
Literal = _PLACEHOLDER
LiteralString = _PLACEHOLDER
Iterable = _PLACEHOLDER
Generator = _PLACEHOLDER
Iterator = _PLACEHOLDER
Hashable = _PLACEHOLDER
TypeVar = _PLACEHOLDER
Self = _PLACEHOLDER
Protocol = object
Generic = object
Never = object
TYPE_CHECKING = False
# decorators
overload = lambda x: x
final = lambda x: x
# exhaustiveness checking
assert_never = lambda x: x
TypedDict = dict
NotRequired = _PLACEHOLDER</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/traceback/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">traceback</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/unicodedata/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">unicodedata</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "typing", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

View File

@ -0,0 +1,354 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>unicodedata | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="unicodedata | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Returns the East Asian width of a Unicode character. The width is one of the following values:">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/unicodedata/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/unicodedata/">
<meta property="og:title" content="unicodedata | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Returns the East Asian width of a Unicode character. The width is one of the following values:">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/unicodedata/">
<meta property="twitter:title" content="unicodedata | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Returns the East Asian width of a Unicode character. The width is one of the following values:">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="unicodedata" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#unicodedata">#</doc-anchor-trigger>
<span>unicodedata</span>
</h1>
</doc-anchor-target>
<doc-anchor-target id="unicodedataeast_asian_widthchar-str---str">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#unicodedataeast_asian_widthchar-str---str">#</doc-anchor-trigger>
<span><code v-pre>unicodedata.east_asian_width(char: str) -&gt; str</code></span>
</h3>
</doc-anchor-target>
<p>Returns the East Asian width of a Unicode character. The width is one of the following values:</p>
<ul>
<li><code v-pre>F</code>: Fullwidth</li>
<li><code v-pre>H</code>: Halfwidth</li>
<li><code v-pre>N</code>: Neutral</li>
<li><code v-pre>Na</code>: Narrow</li>
<li><code v-pre>W</code>: Wide</li>
<li><code v-pre>A</code>: Ambiguous</li>
</ul>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/typing/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">typing</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../modules/vmath/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">vmath</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "unicodedata", level: 2, icon: "file", hasPrism: false, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

573
modules/vmath/index.html Normal file
View File

@ -0,0 +1,573 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>vmath | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="vmath | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Provide vector math operations.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/modules/vmath/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/modules/vmath/">
<meta property="og:title" content="vmath | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Provide vector math operations.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/modules/vmath/">
<meta property="twitter:title" content="vmath | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Provide vector math operations.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../../static/logo.png" rel="icon">
<link href="../../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="vmath" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#vmath">#</doc-anchor-trigger>
<span>vmath</span>
</h1>
</doc-anchor-target>
<p>Provide vector math operations.</p>
<doc-anchor-target id="source-code">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#source-code">#</doc-anchor-trigger>
<span>Source code</span>
</h4>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-python"><code v-pre class="language-python">from typing import overload, Iterator
class _vecF[T]:
ONE: T
ZERO: T
def __add__(self, other: T) -&gt; T: ...
def __sub__(self, other: T) -&gt; T: ...
@overload
def __mul__(self, other: float) -&gt; T: ...
@overload
def __mul__(self, other: T) -&gt; T: ...
def __truediv__(self, other: float) -&gt; T: ...
def dot(self, other: T) -&gt; float: ...
def length(self) -&gt; float: ...
def length_squared(self) -&gt; float: ...
def normalize(self) -&gt; T: ...
# dummy iter for unpacking
def __iter__(self) -&gt; Iterator[float]: ...
class _vecI[T]:
ONE: T
ZERO: T
def __add__(self, other: T) -&gt; T: ...
def __sub__(self, other: T) -&gt; T: ...
@overload
def __mul__(self, other: int) -&gt; T: ...
@overload
def __mul__(self, other: T) -&gt; T: ...
def __floordiv__(self, other: int) -&gt; T: ...
def __hash__(self) -&gt; int: ...
def dot(self, other: T) -&gt; int: ...
# dummy iter for unpacking
def __iter__(self) -&gt; Iterator[int]: ...
class vec2(_vecF['vec2']):
LEFT: vec2
RIGHT: vec2
UP: vec2
DOWN: vec2
@property
def x(self) -&gt; float: ...
@property
def y(self) -&gt; float: ...
def with_x(self, x: float) -&gt; vec2: ...
def with_y(self, y: float) -&gt; vec2: ...
def with_z(self, z: float) -&gt; vec3: ...
@overload
def __init__(self, x: float, y: float) -&gt; None: ...
@overload
def __init__(self, xy: vec2i) -&gt; None: ...
def rotate(self, radians: float) -&gt; vec2:
&quot;&quot;&quot;Rotate the vector by `radians`.
+ If y axis is top to bottom, positive value means clockwise (default)
+ If y axis is bottom to top, positive value means counter-clockwise
&quot;&quot;&quot;
@staticmethod
def angle(__from: vec2, __to: vec2) -&gt; float:
&quot;&quot;&quot;Return the angle in radians between vectors `from` and `to`.
The result range is `[-pi, pi]`.
+ If y axis is top to bottom, positive value means clockwise (default)
+ If y axis is bottom to top, positive value means counter-clockwise
&quot;&quot;&quot;
@staticmethod
def smooth_damp(current: vec2, target: vec2, current_velocity: vec2, smooth_time: float, max_speed: float, delta_time: float) -&gt; tuple[vec2, vec2]:
&quot;&quot;&quot;Smoothly change a vector towards a desired goal over time.
Returns a new value that is closer to the target and current velocity.
&quot;&quot;&quot;
class mat3x3:
def __init__(self, _11, _12, _13, _21, _22, _23, _31, _32, _33) -&gt; None: ...
def __getitem__(self, index: tuple[int, int]) -&gt; float: ...
def __setitem__(self, index: tuple[int, int], value: float) -&gt; None: ...
@overload
def __matmul__(self, other: mat3x3) -&gt; mat3x3: ...
@overload
def __matmul__(self, other: vec3) -&gt; vec3: ...
def __invert__(self) -&gt; mat3x3: ...
def matmul(self, other: mat3x3, out: mat3x3) -&gt; mat3x3 | None: ...
def determinant(self) -&gt; float: ...
def copy(self) -&gt; mat3x3: ...
def inverse(self) -&gt; mat3x3: ...
def copy_(self, other: mat3x3) -&gt; None: ...
def inverse_(self) -&gt; None: ...
@staticmethod
def zeros() -&gt; mat3x3: ...
@staticmethod
def identity() -&gt; mat3x3: ...
# affine transformations
@staticmethod
def trs(t: vec2, r: float, s: vec2) -&gt; mat3x3: ...
def copy_trs_(self, t: vec2, r: float, s: vec2) -&gt; None: ...
def t(self) -&gt; vec2: ...
def r(self) -&gt; float: ...
def s(self) -&gt; vec2: ...
def transform_point(self, p: vec2) -&gt; vec2: ...
def transform_vector(self, v: vec2) -&gt; vec2: ...
class vec2i(_vecI['vec2i']):
LEFT: vec2i
RIGHT: vec2i
UP: vec2i
DOWN: vec2i
@property
def x(self) -&gt; int: ...
@property
def y(self) -&gt; int: ...
def with_x(self, x: int) -&gt; vec2i: ...
def with_y(self, y: int) -&gt; vec2i: ...
def __init__(self, x: int, y: int) -&gt; None: ...
class vec3i(_vecI['vec3i']):
@property
def x(self) -&gt; int: ...
@property
def y(self) -&gt; int: ...
@property
def z(self) -&gt; int: ...
def with_x(self, x: int) -&gt; vec3i: ...
def with_y(self, y: int) -&gt; vec3i: ...
def with_z(self, z: int) -&gt; vec3i: ...
def __init__(self, x: int, y: int, z: int) -&gt; None: ...
class vec3(_vecF['vec3']):
@property
def x(self) -&gt; float: ...
@property
def y(self) -&gt; float: ...
@property
def z(self) -&gt; float: ...
@property
def xy(self) -&gt; vec2: ...
def with_x(self, x: float) -&gt; vec3: ...
def with_y(self, y: float) -&gt; vec3: ...
def with_z(self, z: float) -&gt; vec3: ...
def with_xy(self, xy: vec2) -&gt; vec3: ...
@overload
def __init__(self, x: float, y: float, z: float) -&gt; None: ...
@overload
def __init__(self, xyz: vec3i) -&gt; None: ...
# Color32
class color32:
def __new__(cls, r: int, g: int, b: int, a: int) -&gt; 'color32': ...
def __eq__(self, other: object) -&gt; bool: ...
def __ne__(self, other: object) -&gt; bool: ...
def __repr__(self) -&gt; str: ...
def __hash__(self) -&gt; int: ...
@property
def r(self) -&gt; int: ...
@property
def g(self) -&gt; int: ...
@property
def b(self) -&gt; int: ...
@property
def a(self) -&gt; int: ...
def with_r(self, r: int) -&gt; 'color32': ...
def with_g(self, g: int) -&gt; 'color32': ...
def with_b(self, b: int) -&gt; 'color32': ...
def with_a(self, a: int) -&gt; 'color32': ...
@staticmethod
def from_hex(hex: str) -&gt; 'color32': ...
@staticmethod
def from_vec3(vec: vec3) -&gt; 'color32': ...
@staticmethod
def from_vec3i(vec: vec3i) -&gt; 'color32': ...
def to_hex(self) -&gt; str: ...
def to_vec3(self) -&gt; vec3: ...
def to_vec3i(self) -&gt; vec3i: ...
def ansi_fg(self, text: str) -&gt; str: ...
def ansi_bg(self, text: str) -&gt; str: ...
@staticmethod
def alpha_blend(src: color32, dst: color32 | None) -&gt; color32: ...
def rgb(r: int, g: int, b: int) -&gt; color32: ...
def rgba(r: int, g: int, b: int, a: float) -&gt; color32: ...</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../modules/unicodedata/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">unicodedata</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../gsoc2025/guide/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Application Guide</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "vmath", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

533
performance/index.html Normal file
View File

@ -0,0 +1,533 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Performance | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Performance | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="Currently, pkpy is as fast as cpython 3.9. Performance results for cpython 3.9 are applicable to for pkpy.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/performance/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/performance/">
<meta property="og:title" content="Performance | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="Currently, pkpy is as fast as cpython 3.9. Performance results for cpython 3.9 are applicable to for pkpy.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/performance/">
<meta property="twitter:title" content="Performance | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="Currently, pkpy is as fast as cpython 3.9. Performance results for cpython 3.9 are applicable to for pkpy.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../static/logo.png" rel="icon">
<link href="../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="performance" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#performance">#</doc-anchor-trigger>
<span>Performance</span>
</h1>
</doc-anchor-target>
<p>Currently, pkpy is as fast as cpython 3.9.
Performance results for cpython 3.9 are applicable to for pkpy.</p>
<p>Here is a benchmark result of <code v-pre>v1.2.6</code>.
Files are located in <code v-pre>benchmarks/</code>.</p>
<doc-anchor-target id="win32-64-bit-cpy39">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#win32-64-bit-cpy39">#</doc-anchor-trigger>
<span>win32 64-bit cpy39</span>
</h2>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">CPython: 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]
System: 64-bit
Testing directory: benchmarks/
&gt; benchmarks/fib.py
cpython: 0.986091s (100%)
pocketpy: 0.985427s (99.93%)
&gt; benchmarks/loop_0.py
cpython: 0.515685s (100%)
pocketpy: 0.344132s (66.73%)
&gt; benchmarks/loop_1.py
cpython: 0.938407s (100%)
pocketpy: 0.595634s (63.47%)
&gt; benchmarks/loop_2.py
cpython: 1.188671s (100%)
pocketpy: 0.735259s (61.86%)
&gt; benchmarks/loop_3.py
cpython: 4.957218s (100%)
pocketpy: 2.314210s (46.68%)
&gt; benchmarks/primes.py
cpython: 9.146332s (100%)
pocketpy: 8.507227s (93.01%)
&gt; benchmarks/recursive.py
cpython: 0.044789s (100%)
pocketpy: 0.031252s (69.78%)
&gt; benchmarks/simple.py
cpython: 0.516624s (100%)
pocketpy: 0.453159s (87.72%)
&gt; benchmarks/sort.py
cpython: 0.929597s (100%)
pocketpy: 0.406802s (43.76%)
&gt; benchmarks/sum.py
cpython: 0.047151s (100%)
pocketpy: 0.031266s (66.31%)
ALL TESTS PASSED</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="linux-64-bit-cpy38">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#linux-64-bit-cpy38">#</doc-anchor-trigger>
<span>linux 64-bit cpy38</span>
</h2>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">CPython: 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0]
System: 64-bit
Testing directory: benchmarks/
&gt; benchmarks/fib.py
cpython: 0.739547s (100%)
pocketpy: 0.613591s (82.97%)
&gt; benchmarks/loop_0.py
cpython: 0.356003s (100%)
pocketpy: 0.224396s (63.03%)
&gt; benchmarks/loop_1.py
cpython: 0.661924s (100%)
pocketpy: 0.446577s (67.47%)
&gt; benchmarks/loop_2.py
cpython: 0.937243s (100%)
pocketpy: 0.514324s (54.88%)
&gt; benchmarks/loop_3.py
cpython: 3.671752s (100%)
pocketpy: 1.876151s (51.10%)
&gt; benchmarks/primes.py
cpython: 7.293947s (100%)
pocketpy: 5.427518s (74.41%)
&gt; benchmarks/recursive.py
cpython: 0.021559s (100%)
pocketpy: 0.010227s (47.44%)
&gt; benchmarks/simple.py
cpython: 0.408654s (100%)
pocketpy: 0.265084s (64.87%)
&gt; benchmarks/sort.py
cpython: 0.372539s (100%)
pocketpy: 0.243566s (65.38%)
&gt; benchmarks/sum.py
cpython: 0.021242s (100%)
pocketpy: 0.010113s (47.61%)
ALL TESTS PASSED</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="linux-32-bit-cpy39">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#linux-32-bit-cpy39">#</doc-anchor-trigger>
<span>linux 32-bit cpy39</span>
</h2>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">CPython: 3.9.18 (main, Aug 26 2023, 11:50:23) [GCC 10.3.1 20211027]
System: 32-bit
Testing directory: benchmarks/
&gt; benchmarks/fib.py
cpython: 1.967908s (100%)
pocketpy: 0.960947s (48.83%)
&gt; benchmarks/loop_0.py
cpython: 1.063461s (100%)
pocketpy: 0.396626s (37.30%)
&gt; benchmarks/loop_1.py
cpython: 1.563821s (100%)
pocketpy: 0.639663s (40.90%)
&gt; benchmarks/loop_2.py
cpython: 2.626848s (100%)
pocketpy: 0.757444s (28.83%)
&gt; benchmarks/loop_3.py
cpython: 13.428345s (100%)
pocketpy: 2.852351s (21.24%)
&gt; benchmarks/primes.py
cpython: 18.174904s (100%)
pocketpy: 8.423515s (46.35%)
&gt; benchmarks/recursive.py
cpython: 0.025673s (100%)
pocketpy: 0.012470s (48.57%)
&gt; benchmarks/simple.py
cpython: 1.042090s (100%)
pocketpy: 0.480013s (46.06%)
&gt; benchmarks/sort.py
cpython: 0.989279s (100%)
pocketpy: 0.379171s (38.33%)
&gt; benchmarks/sum.py
cpython: 0.024227s (100%)
pocketpy: 0.012477s (51.50%)
ALL TESTS PASSED</code></pre>
</doc-codeblock></div>
<p>See <a href="https://github.com/pocketpy/pocketpy/actions/runs/6511071423/job/17686074263">actions/runs</a>.</p>
<doc-anchor-target id="primes-benchmarks">
<h2>
<doc-anchor-trigger class="header-anchor-trigger" to="#primes-benchmarks">#</doc-anchor-trigger>
<span>Primes benchmarks</span>
</h2>
</doc-anchor-target>
<p>These are the results of the primes benchmark on Intel i5-12400F, WSL (Ubuntu 20.04 LTS).</p>
<div class="table-wrapper scrollbar overflow-hidden">
<table class="comfortable">
<thead>
<tr>
<th>name</th>
<th>version</th>
<th>time</th>
<th>file</th>
</tr>
</thead>
<tbody>
<tr>
<td>c++</td>
<td>gnu++11</td>
<td><code v-pre>0.104s ■□□□□□□□□□□□□□□□</code></td>
<td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.cpp">benchmarks/primes.cpp</a></td>
</tr>
<tr>
<td>lua</td>
<td>5.3.3</td>
<td><code v-pre>1.576s ■■■■■■■■■□□□□□□□</code></td>
<td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.lua">benchmarks/primes.lua</a></td>
</tr>
<tr>
<td>pkpy</td>
<td>1.2.7</td>
<td><code v-pre>2.385s ■■■■■■■■■■■■■□□□</code></td>
<td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.py">benchmarks/primes.py</a></td>
</tr>
<tr>
<td>cpython</td>
<td>3.8.10</td>
<td><code v-pre>2.871s ■■■■■■■■■■■■■■■■</code></td>
<td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.py">benchmarks/primes.py</a></td>
</tr>
</tbody>
</table>
</div>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-bash"><code v-pre class="language-bash">$ time lua benchmarks/primes.lua
real 0m1.576s
user 0m1.514s
sys 0m0.060s
$ time ./main benchmarks/primes.py
real 0m2.385s
user 0m2.247s
sys 0m0.100s
$ time python benchmarks/primes.py
real 0m2.871s
user 0m2.798s
sys 0m0.060s</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../coding-style-guide/">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Coding Style Guide</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../license/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">License</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Performance", level: 1, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

468
quick-start/index.html Normal file
View File

@ -0,0 +1,468 @@
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.11.0.811925382131">
<!-- See retype.com -->
<meta name="generator" content="Retype 3.11.0">
<!-- Primary Meta Tags -->
<title>Quick Start | Portable Python 3.x Interpreter in Modern C</title>
<meta name="title" content="Quick Start | Portable Python 3.x Interpreter in Modern C">
<meta name="description" content="You have two options to integrate pkpy into your project.">
<!-- Canonical -->
<link rel="canonical" href="https://pocketpy.dev/quick-start/">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://pocketpy.dev/quick-start/">
<meta property="og:title" content="Quick Start | Portable Python 3.x Interpreter in Modern C">
<meta property="og:description" content="You have two options to integrate pkpy into your project.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://pocketpy.dev/quick-start/">
<meta property="twitter:title" content="Quick Start | Portable Python 3.x Interpreter in Modern C">
<meta property="twitter:description" content="You have two options to integrate pkpy into your project.">
<script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
<link href="../static/logo.png" rel="icon">
<link href="../resources/css/retype.css?v=3.11.0.811925382131" rel="stylesheet">
<script data-cfasync="false" src="../resources/js/config.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script data-cfasync="false" src="../resources/js/retype.js?v=3.11.0" data-turbo-eval="false" defer></script>
<script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=3.11.0.811925382131" data-turbo-eval="false" defer></script>
<script id="prism-js" data-cfasync="false" src="../resources/js/prism.js?v=3.11.0.811925382131" defer></script>
</head>
<body>
<div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
<div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
<header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
<div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
<!-- Mobile menu button skeleton -->
<button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-none rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
<div v-cloak id="retype-sidebar-left-toggle-button"></div>
<!-- Logo -->
<div class="flex items-center justify-between h-full py-2 md:w-75">
<div class="flex items-center px-2 md:px-6">
<a id="retype-branding-logo" href="../" class="flex items-center leading-snug text-2xl">
<span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
<img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png">
<img class="max-h-10 hidden dark:inline-block" src="../static/logo.png">
</span>
<span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
</a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.2</span>
</div>
<span class="hidden h-8 border-r md:inline-block border-base-border"></span>
</div>
<div class="flex justify-between md:grow">
<!-- Top Nav -->
<nav id="retype-header-nav" class="hidden md:flex">
<ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
<!-- Header Right Skeleton -->
<div v-cloak class="flex justify-end grow skeleton">
<!-- Search input mock -->
<div class="relative hidden w-40 lg:block lg:max-w-sm lg:ml-auto">
<div class="absolute flex items-center justify-center h-full pl-3 dark:text-dark-300">
<svg xmlns="http://www.w3.org/2000/svg" class="icon-base" width="16" height="16" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 1px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<input class="w-full h-10 placeholder-search-placeholder transition-colors duration-200 ease-in bg-search-bg border border-transparent rounded md:text-sm hover:border-search-border-hover focus:outline-none focus:border-search-border-focus" style="padding: 0.625rem 0.75rem 0.625rem 2rem" type="text" placeholder="Search">
</div>
<!-- Mobile search button -->
<div class="flex items-center justify-center w-10 h-10 lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="20" height="20" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><path d="M21.71 20.29l-3.68-3.68A8.963 8.963 0 0020 11c0-4.96-4.04-9-9-9s-9 4.04-9 9 4.04 9 9 9c2.12 0 4.07-.74 5.61-1.97l3.68 3.68c.2.19.45.29.71.29s.51-.1.71-.29c.39-.39.39-1.03 0-1.42zM4 11c0-3.86 3.14-7 7-7s7 3.14 7 7c0 1.92-.78 3.66-2.04 4.93-.01.01-.02.01-.02.01-.01.01-.01.01-.01.02A6.98 6.98 0 0111 18c-3.86 0-7-3.14-7-7z" ></path></g></svg>
</div>
<!-- Dark mode switch placeholder -->
<div class="w-10 h-10 lg:ml-2"></div>
<!-- History button -->
<div class="flex items-center justify-center w-10 h-10" style="margin-right: -0.625rem;">
<svg xmlns="http://www.w3.org/2000/svg" class="shrink-0 icon-base" width="22" height="22" viewBox="0 0 24 24" aria-labelledby="icon" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor" ><g ><path d="M12.01 6.01c-.55 0-1 .45-1 1V12a1 1 0 00.4.8l3 2.22a.985.985 0 001.39-.2.996.996 0 00-.21-1.4l-2.6-1.92V7.01c.02-.55-.43-1-.98-1z"></path><path d="M12.01 1.91c-5.33 0-9.69 4.16-10.05 9.4l-.29-.26a.997.997 0 10-1.34 1.48l1.97 1.79c.19.17.43.26.67.26s.48-.09.67-.26l1.97-1.79a.997.997 0 10-1.34-1.48l-.31.28c.34-4.14 3.82-7.41 8.05-7.41 4.46 0 8.08 3.63 8.08 8.09s-3.63 8.08-8.08 8.08c-2.18 0-4.22-.85-5.75-2.4a.996.996 0 10-1.42 1.4 10.02 10.02 0 007.17 2.99c5.56 0 10.08-4.52 10.08-10.08.01-5.56-4.52-10.09-10.08-10.09z"></path></g></g></svg>
</div>
</div>
<div v-cloak class="flex justify-end grow">
<div id="retype-mobile-search-button"></div>
<doc-search-desktop></doc-search-desktop>
<doc-theme-switch class="lg:ml-2"></doc-theme-switch>
<doc-history></doc-history>
</div>
</div>
</div>
</header>
<div id="retype-container" class="container relative flex bg-white">
<!-- Sidebar Skeleton -->
<div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
<div class="flex items-center h-16 px-6">
<input class="w-full h-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded shadow-none text-sm focus:outline-none focus:border-filter-border-focus" type="text" placeholder="Filter">
</div>
<div class="pl-6 mt-1 mb-4">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
<div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</div>
<!-- Sidebar component -->
<doc-sidebar v-cloak>
<template #sidebar-footer>
<div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
<div class="py-3 px-6 md:hidden border-b dark:border-base-border">
<nav>
<ul class="flex flex-wrap justify-center items-center">
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
</g>
</svg>
<span>Home</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
</g>
</svg>
<span>Live Demo</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
</g>
</svg>
<span>Live Examples</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M12 1C5.923 1 1 5.923 1 12c0 4.867 3.149 8.979 7.521 10.436.55.096.756-.233.756-.522 0-.262-.013-1.128-.013-2.049-2.764.509-3.479-.674-3.699-1.292-.124-.317-.66-1.293-1.127-1.554-.385-.207-.936-.715-.014-.729.866-.014 1.485.797 1.691 1.128.99 1.663 2.571 1.196 3.204.907.096-.715.385-1.196.701-1.471-2.448-.275-5.005-1.224-5.005-5.432 0-1.196.426-2.186 1.128-2.956-.111-.275-.496-1.402.11-2.915 0 0 .921-.288 3.024 1.128a10.193 10.193 0 0 1 2.75-.371c.936 0 1.871.123 2.75.371 2.104-1.43 3.025-1.128 3.025-1.128.605 1.513.221 2.64.111 2.915.701.77 1.127 1.747 1.127 2.956 0 4.222-2.571 5.157-5.019 5.432.399.344.743 1.004.743 2.035 0 1.471-.014 2.654-.014 3.025 0 .289.206.632.756.522C19.851 20.979 23 16.854 23 12c0-6.077-4.922-11-11-11Z"/>
</g>
</svg>
<span>Github</span>
</a>
</li>
<li class="mr-6">
<a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text-weight hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
<g fill="currentColor">
<path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
</g>
</svg>
<span>Discord</span>
</a>
</li>
</ul>
</nav>
</div>
<a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
<span class="text-xs whitespace-nowrap">Powered by</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
</a>
</div>
</template>
</doc-sidebar>
<div class="grow min-w-0 bg-body-bg">
<!-- Render "toolbar" template here on api pages --><!-- Render page content -->
<div class="flex">
<div id="retype-main" class="min-w-0 p-4 grow md:px-16">
<main class="relative pb-12 lg:pt-2">
<div class="retype-markdown" id="retype-content">
<!-- Rendered if sidebar right is enabled -->
<div id="retype-sidebar-right-toggle"></div>
<!-- Page content -->
<doc-anchor-target id="quick-start" class="break-words">
<h1>
<doc-anchor-trigger class="header-anchor-trigger" to="#quick-start">#</doc-anchor-trigger>
<span>Quick Start</span>
</h1>
</doc-anchor-target>
<p>You have two options to integrate pkpy into your project.</p>
<doc-anchor-target id="use-the-single-header-file">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#use-the-single-header-file">#</doc-anchor-trigger>
<span>Use the single header file</span>
</h4>
</doc-anchor-target>
<p>Download the <code v-pre>pocketpy.h</code> and <code v-pre>pocketpy.c</code> on our <a href="https://github.com/pocketpy/pocketpy/releases">GitHub Release</a> page.
And <code v-pre>#include</code> it in your project.</p>
<doc-anchor-target id="use-cmake">
<h4>
<doc-anchor-trigger class="header-anchor-trigger" to="#use-cmake">#</doc-anchor-trigger>
<span>Use CMake</span>
</h4>
</doc-anchor-target>
<p>Clone the whole repository as a submodule into your project,
In your CMakelists.txt, add the following lines:</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-cmake"><code v-pre class="language-cmake">add_subdirectory(pocketpy)
target_link_libraries(&lt;your_target&gt; pocketpy)</code></pre>
</doc-codeblock></div>
<p>See <a href="https://github.com/pocketpy/pocketpy/blob/main/CMakeLists.txt">CMakeLists.txt</a> for details.</p>
<p>It is safe to use <code v-pre>main</code> branch in production if CI badge is green.</p>
<doc-anchor-target id="compile-flags">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#compile-flags">#</doc-anchor-trigger>
<span>Compile flags</span>
</h3>
</doc-anchor-target>
<p>To compile it with your project, these flags must be set:</p>
<ul>
<li><code v-pre>--std=c11</code> flag must be set</li>
<li>For MSVC, <code v-pre>/utf-8</code> and <code v-pre>/experimental:c11atomics</code> flag must be set</li>
<li><code v-pre>NDEBUG</code> macro should be defined for release build, or you will get poor performance</li>
</ul>
<doc-anchor-target id="get-prebuilt-binaries">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#get-prebuilt-binaries">#</doc-anchor-trigger>
<span>Get prebuilt binaries</span>
</h3>
</doc-anchor-target>
<p>We have prebuilt binaries,
check them out on our <a href="https://github.com/pocketpy/pocketpy/actions/workflows/main.yml">GitHub Actions</a>.</p>
<p>You can download an artifact there which contains the following files.</p>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-none"><code v-pre class="language-none">├── android
│   ├── arm64-v8a
│   │   └── libpocketpy.so
│   ├── armeabi-v7a
│   │   └── libpocketpy.so
│   └── x86_64
│   └── libpocketpy.so
├── ios
│   └── libpocketpy.a
├── linux
│   └── x86_64
│   ├── libpocketpy.so
│   └── main
└── windows
└── x86_64
├── main.exe
└── pocketpy.dll</code></pre>
</doc-codeblock></div>
<doc-anchor-target id="example">
<h3>
<doc-anchor-trigger class="header-anchor-trigger" to="#example">#</doc-anchor-trigger>
<span>Example</span>
</h3>
</doc-anchor-target>
<div class="codeblock-wrapper"><doc-codeblock>
<pre translate="no" class="language-c"><code v-pre class="language-c">#include &quot;pocketpy.h&quot;
#include &lt;stdio.h&gt;
static bool int_add(int argc, py_Ref argv) {
PY_CHECK_ARGC(2);
PY_CHECK_ARG_TYPE(0, tp_int);
PY_CHECK_ARG_TYPE(1, tp_int);
py_i64 a = py_toint(py_arg(0));
py_i64 b = py_toint(py_arg(1));
py_newint(py_retval(), a + b);
return true;
}
int main() {
// Initialize pocketpy
py_initialize();
// Hello world!
bool ok = py_exec(&quot;print('Hello world!')&quot;, &quot;&lt;string&gt;&quot;, EXEC_MODE, NULL);
if(!ok) goto __ERROR;
// Create a list: [1, 2, 3]
py_Ref r0 = py_getreg(0);
py_newlistn(r0, 3);
py_newint(py_list_getitem(r0, 0), 1);
py_newint(py_list_getitem(r0, 1), 2);
py_newint(py_list_getitem(r0, 2), 3);
// Eval the sum of the list
py_Ref f_sum = py_getbuiltin(py_name(&quot;sum&quot;));
py_push(f_sum);
py_pushnil();
py_push(r0);
ok = py_vectorcall(1, 0);
if(!ok) goto __ERROR;
printf(&quot;Sum of the list: %d\n&quot;, (int)py_toint(py_retval())); // 6
// Bind native `int_add` as a global variable
py_newnativefunc(r0, int_add);
py_setglobal(py_name(&quot;add&quot;), r0);
// Call `add` in python
ok = py_exec(&quot;add(3, 7)&quot;, &quot;&lt;string&gt;&quot;, EVAL_MODE, NULL);
if(!ok) goto __ERROR;
py_i64 res = py_toint(py_retval());
printf(&quot;Sum of 2 variables: %d\n&quot;, (int)res); // 10
py_finalize();
return 0;
__ERROR:
py_printexc();
py_finalize();
return 1;
}</code></pre>
</doc-codeblock></div>
<!-- Required only on API pages -->
<doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
</div>
<footer id="retype-content-footer" class="clear-both">
<nav id="retype-nextprev" class="print:hidden flex mt-14">
<div class="w-1/2">
<a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../">
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
<span>
<span class="block text-xs font-normal text-base-text-muted">Previous</span>
<span class="block mt-1">Welcome</span>
</span>
</a>
</div>
<div class="w-1/2">
<a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../bindings/">
<span>
<span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
<span class="block mt-1">Write C Bindings</span>
</span>
<svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
</a>
</div>
</nav>
</footer>
</main>
<div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
<footer class="flex flex-wrap items-center justify-between print:justify-center">
<div id="retype-footer-links" class="print:hidden">
<ul class="flex flex-wrap items-center text-sm">
</ul>
</div>
<div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link-weight text-sm leading-relaxed"><p>© Copyright 2025 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
</footer>
</div>
</div>
<!-- Rendered if sidebar right is enabled -->
<!-- Sidebar right skeleton-->
<div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:transform-none sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
<div class="pl-5">
<div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
<div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
</div>
</div>
<!-- User should be able to hide sidebar right -->
<doc-sidebar-right v-cloak></doc-sidebar-right>
</div>
</div>
</div>
<doc-search-mobile></doc-search-mobile>
<doc-back-to-top></doc-back-to-top>
</div>
<div id="retype-overlay-target"></div>
<script data-cfasync="false">window.__DOCS__ = { "title": "Quick Start", level: 1, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
</body>
</html>

5
resources/css/retype.css Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

1
resources/js/config.js Normal file

File diff suppressed because one or more lines are too long

39
resources/js/lunr.js Normal file

File diff suppressed because one or more lines are too long

4
resources/js/mermaid.js Normal file

File diff suppressed because one or more lines are too long

5
resources/js/prism.js Normal file

File diff suppressed because one or more lines are too long

27
resources/js/retype.js Normal file

File diff suppressed because one or more lines are too long

1
resources/js/search.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,61 @@
/*!
* lunr.Builder
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.Index
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.Pipeline
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.Set
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.TokenSet
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.Vector
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.stemmer
* Copyright (C) 2020 Oliver Nightingale
* Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
*/
/*!
* lunr.stopWordFilter
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.tokenizer
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.trimmer
* Copyright (C) 2020 Oliver Nightingale
*/
/*!
* lunr.utils
* Copyright (C) 2020 Oliver Nightingale
*/
/**
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9
* Copyright (C) 2020 Oliver Nightingale
* @license MIT
*/

View File

@ -0,0 +1,26 @@
/*!
Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
Licensed under The MIT License (http://opensource.org/licenses/MIT)
*/
/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */
/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */
/*! Bundled license information:
js-yaml/dist/js-yaml.mjs:
(*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
*/
/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */
/**
* Mermaid is a Javascript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams.
*
* @license MIT <https://opensource.org/licenses/MIT>
* @author Knut Sveidqvist <https://github.com/knsv>
* @namespace
* @public
*/

View File

@ -0,0 +1,8 @@
/**
* Prism: Lightweight, robust, elegant syntax highlighting
*
* @license MIT <https://opensource.org/licenses/MIT>
* @author Lea Verou <https://lea.verou.me>
* @namespace
* @public
*/

View File

@ -0,0 +1,248 @@
Retype Software License Agreement
Version 3.11.0
THIS DOCUMENT IS A LEGAL AGREEMENT (the "License Agreement") BETWEEN OBJECT.NET, INC. ("We," "Us")
AND YOU OR THE ORGANIZATION ON WHOSE BEHALF YOU ARE UNDERTAKING THE LICENSE DESCRIBED BELOW ("You",
"Your") IN RELATION TO THE RETYPE SOFTWARE LIBRARY(IES) (THE "Software"), IN BOTH SOURCE AND OBJECT
CODE FORM, AND/OR ALL RELATED MATERIALS.
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING THE SOFTWARE, YOU ACCEPT THE FOLLOWING TERMS
AND CONDITIONS. IF YOU DO NOT AGREE WITH ANY OF THE TERMS OR CONDITIONS OF THIS LICENSE AGREEMENT,
DO NOT PROCEED WITH THE DOWNLOADING, COPYING, INSTALLATION OR ANY OTHER USE OF THE SOFTWARE OR ANY
PORTION THEREOF AS YOU HAVE NO RIGHTS TO DO SO. THE SOFTWARE IS PROTECTED BY UNITED STATES
COPYRIGHT LAWS AND INTERNATIONAL COPYRIGHT LAWS, AS WELL AS OTHER INTELLECTUAL PROPERTY LAWS AND
TREATIES. THE SOFTWARE IS LICENSED, NOT SOLD.
THIS LICENSE AGREEMENT DESCRIBES YOUR RIGHTS AND RESTRICTIONS WITH RESPECT TO THE SOFTWARE AND
ITS COMPONENTS.
1. DEFINITIONS
"Application" means any software, application, or elements that Your Designated Users develop using
the Software or Modifications in accordance with this Agreement; provided that any such Application
(i) must have substantially different functionality than the Software, and (ii) must not allow any
third party to use the Software or Modifications, or any portion thereof, for software development
or application development purposes.
"Designated User" shall mean a single distinct person for whom You have purchased a license to use
the Software, whether such person is an employee acting within the scope of their employment with
You or Your consultant or contractor acting within the scope of the services they provide for You.
A Designated User can be replaced with a new Designated User only after being a Designated User
for a minimum of six (6) months.
"End User" means an end user of Your Application who acquires a license to such solely for their
own internal use and not for distribution, resale, user interface design, or software development
purposes.
"Modification" means: a) any addition to or deletion from the contents of a file included in the
original Software or previous Modifications created by You, and/or b) any new file that leverages
any part of the original Software or previous Modifications.
"Sample Code" means sample source code included with the Software and designated as "sample code,"
"samples," "sample application code," and/or "snippets," and/or found in directories labeled
"samples", "learn", "docs", "examples" or "examples explorer".
2. LICENSE GRANT
Subject to the payment of the fee required, and subject to your compliance with all of the terms
and conditions of this Agreement, We grant to You a revocable, non-exclusive, non-transferable and
non-sublicensable license (i) for Designated User(s) to use the Software to create Modifications
and Applications; (ii) for You to distribute the Software and/or Modifications to End Users solely
as integrated into the Applications; and (iii) for End Users to use the Software as integrated into
Your Applications in accordance with the terms of this Agreement.
In addition to the other terms contained herein, We grant to You a revocable, non-exclusive,
non-transferable and non-sublicensable license to install and use the Software (the "Free License")
for Your internal evaluation, review, and production purposes. The Free License may contain
restricted functionality. You are explicitly not permitted to distribute the Software to any user
outside the Organization on whose behalf you have undertaken this license. We reserve the right to
terminate Your License at any time in Our absolute and sole discretion. Without the purchase and
inclusion of a License Key, the Software may contain restricted functionality, which from
time-to-time may differ in its limitations. If you wish to remove these restrictions, you are
required to purchase a Retype License Key; otherwise you must leave this limitation intact and not
attempt to modify or circumvent it in any way.
In addition to the other terms contained herein, in the event You have downloaded or received beta
or pre-release versions of the Software (the "Beta Software") from Us, We grant to You a revocable,
non-exclusive, non-transferable and non-sublicensable license to install and use the Beta Software
strictly for Your internal evaluation and review purposes and not for production purposes (the
"Beta License"). You are explicitly not permitted to distribute the Software to any user outside
the Organization on whose behalf you have undertaken this license. Your rights to use the Beta
Software will immediately terminate upon the earlier of (i) the expiration of the evaluation period
established by Us, or (ii) such time that You purchase a license to a non-evaluation version of the
Software. We reserve the right to terminate Your Beta License at any time in Our absolute and sole
discretion.
YOU ACKNOWLEDGE THAT TRIAL AND/OR BETA SOFTWARE MIGHT PLACE WATERMARKS ON OUTPUT, CONTAIN LIMITED
FUNCTIONALITY, FUNCTION FOR A LIMITED PERIOD OF TIME, OR LIMIT THE FUNCTIONALITY OR TIME OF
FUNCTIONING OF ANY OUTPUT. ACCESS TO AND/OR USE OF ANY FILES OR OUTPUT CREATED WITH SUCH SOFTWARE
IS ENTIRELY AT YOUR OWN RISK. WE ARE LICENSING THE SOFTWARE ON AN "AS IS" BASIS AT YOUR OWN RISK
AND WE DISCLAIM ANY WARRANTY OR LIABILITY TO YOU OF ANY KIND.
You may modify the "Sample Code" solely for the purposes of designing, developing and testing Your
own Applications. However, You are permitted to use, copy and redistribute Your modified Sample
Code only if all of the following conditions are met: (a) You include Our copyright notice (if any)
with Your Application, including every location in which any other copyright notice appears in such
Application; and (b) You do not otherwise use Our name, logos or other of Our trademarks to market
Your Application, unless otherwise agree by Us in writing.
3. OWNERSHIP
This is a license agreement and not an agreement for sale. We reserve ownership of all intellectual
property rights inherent in or relating to the Software, which include, but are not limited to, all
copyright, patent rights, all rights in relation to registered and unregistered trademarks
(including service marks), confidential information (including trade secrets and know-how) and all
rights other than those expressly granted by this Agreement.
We may provide You with source code so that You can create Modifications and Applications. While You
retain all rights to any original work authored by You as part of the Modifications, We continue to
own all copyright and other intellectual property rights in the Software.
You must not remove, obscure or interfere with any copyright, acknowledgment, attribution,
trademark, warning or disclaimer statement affixed to, incorporated in or otherwise applied in
connection with the Software.
4. PROHIBITED USES
You may not redistribute the Software or Modifications other than by including the Software or a
portion thereof within Your Application. You may not redistribute the Software or Modifications as
part of any Application that can be described as a development toolkit or library, an application
builder, a website builder or any Application that is intended for use by software, application, or
website developers or designers. You may not redistribute any part of the Software documentation.
You may not change or remove the copyright notice from any of the files included in the Software or
Modifications.
UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE FOR AN APPLICATION THAT IS INTENDED FOR SOFTWARE OR
APPLICATION DEVELOPMENT PURPOSES.
UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE (INCLUDING WITHOUT LIMITATION THE SOURCE CODE
THEREOF) AS THE BASIS FOR OR IN CONNECTION WITH A PRODUCT THAT CONTAINS THE SAME, OR SUBSTANTIALLY
THE SAME, FUNCTIONALITY AS THE SOFTWARE.
You are required to ensure that the Software is not reused by or with any applications other than
those with which You distribute it as permitted herein. For example, if You install the Software on
a customer's server, that customer is not permitted to use the Software independently of Your
Application, and must be informed as such.
5. TERMINATION
This Agreement and Your right to use the Software and Modifications will terminate immediately if
You fail to comply with any of the terms and conditions of this Agreement. Upon termination, You
agree to immediately cease using and destroy the Software or Modifications, including all
accompanying documents. The provisions of sections 4, 5, 6, 7, 8, 9, and 11 will survive any
termination of this Agreement.
6. DISCLAIMER OF WARRANTIES
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, WE AND OUR RESELLERS DISCLAIM ALL WARRANTIES AND
CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND TITLE AND NON-INFRINGEMENT, WITH REGARD TO
THE SOFTWARE. WE DO NOT GUARANTEE THAT THE OPERATION OF THE SOFTWARE OR THE CODE IT PRODUCES WILL
BE UNINTERRUPTED OR ERROR-FREE, AND YOU ACKNOWLEDGE THAT IT IS NOT TECHNICALLY PRACTICABLE FOR US
TO DO SO.
7. LIMITATION OF LIABILITIES
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL WE OR OUR RESELLERS BE LIABLE
UNDER ANY LEGAL OR EQUITABLE THEORY FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES
WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
INTERRUPTION, LOSS OF BUSINESS INFORMATION OR ANY OTHER PECUNIARY LAW) ARISING OUT OF THE USE OF OR
INABILITY TO USE THE SOFTWARE OR THE CODE IT PRODUCES OR ANY OTHER SUBJECT MATTER RELATING TO THIS
AGREEMENT, EVEN IF WE OR OUR RESELLERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY
CASE, OUR ENTIRE LIABILITY WITH RESPECT TO ANY SUBJECT MATTER RELATING TO THIS AGREEMENT SHALL BE
LIMITED TO THE GREATER OF (I) THE AMOUNT ACTUALLY PAID BY YOU FOR THE SOFTWARE OR (II) ONE HUNDRED
DOLLARS ($100).
8. PAYMENT AND TAXES
If credit has been extended to You by Us, all payments under this Agreement are due within thirty
(30) days of the date We mail an invoice to You. If We have not extended credit to You, You shall
be required to make payment concurrent with the delivery of the Software by Us. Any value added
tax, use tax, sales tax or similar tax ("Transaction Taxes") shall be your sole responsibility.
Each party shall pay all taxes (including, but not limited to, taxes based upon its income) or
levies imposed on it under applicable laws, regulations and tax treaties as a result of this
Agreement and any payments made hereunder (including those required to be withheld or deducted
from payments); provided that You shall be responsible for all Transactions Taxes and shall pay or
reimburse Us for the same upon invoice. Each party shall furnish evidence of such paid taxes as is
sufficient to enable the other party to obtain any credits available to it, including original
withholding tax certificates. Notwithstanding the foregoing, Software ordered through Our resellers
is subject to the fees and payment terms set forth on the applicable reseller invoice.
9. MISCELLANEOUS
The license granted herein applies only to the version of the Software available when purchased in
connection with the terms of this Agreement, and to any updates and/or upgrades to which you may be
entitled. Any previous or subsequent license granted to You for use of the Software shall be
governed by the terms and conditions of the agreement entered in connection with purchase or
download of that version of the Software. You agree that you will comply with all applicable laws
and regulations with respect to the Software, including without limitation all export and re-export
control laws and regulations.
While redistributing the Software or Modifications thereof as part of Your Application, You may
choose to offer acceptance of support, warranty, indemnity, or other liability obligations and/or
rights consistent with this Agreement. However, in accepting such obligations, You may act only on
Your own behalf and on Your sole responsibility, not on our behalf. You shall indemnify Us and our
resellers, or at Our option, defend Us and our resellers against any claim, suit or proceeding
brought against Us or our resellers (i) arising by reason of Your accepting any such support,
warranty, indemnity or additional liability; or (ii) arising out of the use, reproduction or
distribution of Your Application, except to the extent such claim is solely based on the inclusion
of the Software therein. Further, You agree only to distribute the Software pursuant to an
enforceable written agreement for Our benefit that includes all the limitations and restrictions of
this Agreement and is as protective of Us and Software as is this Agreement. For clarity, You must
purchase Designated User licenses for each contractor or consultant who uses the Software to create
an Application on your behalf (including system integrators), whether or not such contractor or
consultant has its own license to the Software.
You agree to be identified as a customer of ours and You agree that We may refer to You by name,
trade name and trademark, if applicable, and may briefly describe Your business in our marketing
materials and web site.
You may not assign or transfer this Agreement without Our prior written consent. This Agreement
may be assigned by Us in whole or part and will inure to the benefit of Our successors and
assigns. Notwithstanding the foregoing, in any instance in which You transfer ownership of an
Application on a work for hire basis, You may assign licenses for the total Designated Users that
have used the Software to develop said Application under this Agreement to another party (Assignee)
provided (i) you provide written notice to Us prior to the effective date of such assignment; and
(ii) there is a written agreement, wherein the Assignee accepts the terms of this Agreement. Upon
any such transfer, the Assignee may appoint new Designated Users.
You acknowledge that this Agreement is complete and is the exclusive representation of our
agreement. No oral or written information given by Us, Our resellers, or otherwise on Our behalf
shall create a warranty or collateral contract, or in any way increase the scope of this Agreement
in any way, and You may not rely on any such oral or written information. No term or condition
contained in any purchase order shall have any force or effect.
There are no implied licenses or other implied rights granted under this Agreement, and all rights,
save for those expressly granted hereunder, shall remain with Us and our licensors. In addition, no
licenses or immunities are granted to the combination of the Software and/or Modifications, as
applicable, with any other software or hardware not delivered by Us or Our resellers to You under
this Agreement. Your rights under this Agreement apply only to Software, Modifications, and/or
Applications for which all Designated Users are duly licensed hereunder.
If any provision in this Agreement shall be determined to be invalid, such provision shall be
deemed omitted; the remainder of this Agreement shall continue in full force and effect. If any
remedy provided is determined to have failed for its essential purpose, all limitations of
liability and exclusions of damages set forth in this Agreement shall remain in effect.
This Agreement may be modified only by a written instrument signed by an authorized representative
of each party. The failure of either party to enforce any provision of this Agreement may not be
deemed a waiver of that or any other provision of this Agreement.
This Agreement is governed by the law of the Province of Alberta, Canada and all parties
irrevocably submit to the jurisdiction of the courts of the Province of Alberta and further agree
to commence any litigation which may arise hereunder in the courts located in the judicial district
of Edmonton, Alberta, Canada.
If the Software or any related documentation is licensed to the U.S. Government or any agency
thereof, it will be considered to be "commercial computer software" or "commercial computer
software documentation," as those terms are used in 48 CFR § 12.212 or 48 CFR § 227.7202, and is
being licensed with only those rights as are granted to all other licensees as set forth in this
Agreement.
Copyright 2008-2021 Object.NET, Inc., All rights reserved.
Object.NET, Inc.
+1(888)775-5888
licensing@object.net
object.net

View File

@ -0,0 +1,28 @@
/*!
* clipboard.js v2.0.11
* https://clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
*/
/*! #__NO_SIDE_EFFECTS__ */
/*! MIT License. Copyright 2015-2018 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */
/**
* @vue/runtime-core v3.5.17
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
/**
* @vue/runtime-dom v3.5.17
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
/**
* @vue/shared v3.5.17
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/

4
robots.txt Normal file
View File

@ -0,0 +1,4 @@
User-agent: *
Allow: /
Sitemap: https://pocketpy.dev/sitemap.xml.gz

BIN
sitemap.xml.gz Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

BIN
static/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
static/profiler_demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

310
static/web/index.html Normal file
View File

@ -0,0 +1,310 @@
<!--
Note:
This site was created by modifying code pen https://codepen.io/antonmedv/pen/PoPoGwg
written by 'Anton Medvedev' the license can be found bellow.
LICENSE
-------
Copyright (c) 2022 by Anton Medvedev (https://codepen.io/antonmedv/pen/PoPoGwg)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="static/codejar/codejar.js"></script>
<script src="static/codejar/linenumbers.js"></script>
<script src="static/highlight.js/highlight.min.js"></script>
<link rel="stylesheet" href="static/highlight.js/github-dark-dimmed.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@300&family=PT+Mono&display=swap");
.hljs {
display: block;
overflow-x: auto;
padding: .5em;
background: #282a36
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-link {
color: #73cbde
}
.hljs,
.hljs-subst {
color: #f8f8f2
}
.hljs-string,
.hljs-title,
.hljs-name,
.hljs-type,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
color: #f1fa8c
}
.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
color: #6272a4
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-title,
.hljs-section,
.hljs-doctag,
.hljs-type,
.hljs-name,
.hljs-strong {
font-weight: bold
}
.hljs-emphasis {
font-style: italic
}
:root {
--window-width: 80%;
}
body {
background-color: #778abb;
font-family: Lato, sans-serif;
font-weight: 300;
font-size: 15px;
margin: 0;
}
*,
*:before,
*:after {
box-sizing: border-box;
}
*:focus {
outline: none;
}
a,
a:visited,
a:active {
color: black;
}
main {
min-height: 100vh;
display: flex;
align-items: center;
flex-direction: column;
}
.title {
color: #fff;
text-align: center;
font-weight: 300;
font-size: 34px;
margin-top: 20px;
}
.window {
width: var(--window-width);
border-radius: 6px;
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
overflow: hidden;
margin-bottom: 20px;
}
.window .window-header {
height: 25px;
background: Gainsboro;
position: relative;
}
.window .window-header .action-buttons {
position: absolute;
top: 50%;
left: 10px;
margin-top: -5px;
width: 10px;
height: 10px;
background: Crimson;
border-radius: 50%;
box-shadow: 15px 0 0 Orange, 30px 0 0 LimeGreen;
}
#code-editor {
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12),
0 3px 1px -2px rgba(0, 0, 0, 0.2);
font-family: "PT Mono", monospace;
font-size: 14px;
font-weight: 400;
min-height: 300px;
letter-spacing: normal;
line-height: 20px;
padding: 10px;
resize: none !important;
tab-size: 4;
}
#run-button {
padding-left: 10px;
padding-right: 10px;
font-weight: bold;
cursor: pointer;
}
#code-editor.hljs {
padding: 10px;
}
#output-wrapper {
font-family: "PT Mono", monospace;
width: var(--window-width);
min-height: 50px;
background-color: #282a36;
border-radius: 6px;
padding: 10px;
color: white;
margin: 0 !important;
}
#code-output span.error-line {
color: #ec5424;
}
.controls {
font-size: 14px;
position: absolute;
top: 50%;
right: 10px;
margin-top: -10px;
display: flex;
}
.controls>div:first-child>a {
display: inline-block;
width: 40px;
}
.features {
width: 547px;
font-size: 16px;
margin-bottom: 30px;
}
</style>
<title>Try Online</title>
</head>
<body id="tryonline-body">
<main>
<br>
<div class="window">
<div class="window-header">
<div class="action-buttons"></div>
<div class="controls">
<div id="run-button">Run</div>
</div>
</div>
<div class="window-body">
<div id="code-editor" class="language-python" data-gramm="false"></div>
</div>
</div>
<pre id="output-wrapper"><div id="code-output">...</div></pre>
<br>
</main>
<script>
var Module = {
onRuntimeInitialized: function () {
Module.ccall('py_initialize', null, [], []);
console.log("py_initialize() called");
},
print: function (text) {
code_output.innerText += text + '\n';
},
onabort: function (what) {
code_output.innerText += 'Aborted: ' + what + '\n';
Module.ccall('py_finalize', null, [], []);
console.log("py_finalize() called");
}
};
</script>
<script src="lib/pocketpy.js"></script>
<script>
let code_editor = document.querySelector('#code-editor');
let code_output = document.querySelector('#code-output');
let run_button = document.querySelector('#run-button');
code_editor.textContent = '# A recursive fibonacci function.\ndef fib(n):\n if n < 2:\n return n\n return fib(n-1) + fib(n-2)\n\n# Prints all fibonacci from 0 to 10 exclusive.\nfor i in range(10):\n print(f"fib({i}) = {fib(i)}")\n';
let highlight = withLineNumbers(function (editor) {
editor.textContent = editor.textContent;
hljs.highlightElement(editor);
});
highlight(code_editor);
CodeJar(code_editor, highlight); //, { indentOn: /[(\[{:]$/});
window.onload = function () {
run_button.onclick = function () {
code_output.innerText = '';
const source = code_editor.textContent;
var ok = Module.ccall(
'py_exec', 'boolean', ['string', 'string', 'number', 'number'],
[source, 'main.py', 0, 0]
);
console.log("py_exec() called");
if (!ok) {
Module.ccall('py_printexc', null, [], []);
Module.ccall('py_clearexc', null, ['number'], [0]);
}
}
}
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

BIN
static/web/lib/pocketpy.wasm Executable file

Binary file not shown.

View File

@ -0,0 +1,423 @@
const globalWindow = window;
function CodeJar(editor, highlight, opt = {}) {
const options = Object.assign({ tab: '\t', indentOn: /{$/, spellcheck: false, catchTab: true, preserveIdent: true, addClosing: true, history: true, window: globalWindow }, opt);
const window = options.window;
const document = window.document;
let listeners = [];
let history = [];
let at = -1;
let focus = false;
let callback;
let prev; // code content prior keydown event
let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
editor.setAttribute('contentEditable', isFirefox ? 'true' : 'plaintext-only');
editor.setAttribute('spellcheck', options.spellcheck ? 'true' : 'false');
editor.style.outline = 'none';
editor.style.overflowWrap = 'break-word';
editor.style.overflowY = 'auto';
editor.style.resize = 'vertical';
editor.style.whiteSpace = 'pre-wrap';
highlight(editor);
const debounceHighlight = debounce(() => {
const pos = save();
highlight(editor, pos);
restore(pos);
}, 30);
let recording = false;
const shouldRecord = (event) => {
return !isUndo(event) && !isRedo(event)
&& event.key !== 'Meta'
&& event.key !== 'Control'
&& event.key !== 'Alt'
&& !event.key.startsWith('Arrow');
};
const debounceRecordHistory = debounce((event) => {
if (shouldRecord(event)) {
recordHistory();
recording = false;
}
}, 300);
const on = (type, fn) => {
listeners.push([type, fn]);
editor.addEventListener(type, fn);
};
on('keydown', event => {
if (event.defaultPrevented)
return;
prev = toString();
if (options.preserveIdent)
handleNewLine(event);
else
firefoxNewLineFix(event);
if (options.catchTab)
handleTabCharacters(event);
if (options.addClosing)
handleSelfClosingCharacters(event);
if (options.history) {
handleUndoRedo(event);
if (shouldRecord(event) && !recording) {
recordHistory();
recording = true;
}
}
});
on('keyup', event => {
if (event.defaultPrevented)
return;
if (event.isComposing)
return;
if (prev !== toString())
debounceHighlight();
debounceRecordHistory(event);
if (callback)
callback(toString());
});
on('focus', _event => {
focus = true;
});
on('blur', _event => {
focus = false;
});
on('paste', event => {
recordHistory();
handlePaste(event);
recordHistory();
if (callback)
callback(toString());
});
function save() {
const s = getSelection();
const pos = { start: 0, end: 0, dir: undefined };
visit(editor, el => {
if (el === s.anchorNode && el === s.focusNode) {
pos.start += s.anchorOffset;
pos.end += s.focusOffset;
pos.dir = s.anchorOffset <= s.focusOffset ? '->' : '<-';
return 'stop';
}
if (el === s.anchorNode) {
pos.start += s.anchorOffset;
if (!pos.dir) {
pos.dir = '->';
}
else {
return 'stop';
}
}
else if (el === s.focusNode) {
pos.end += s.focusOffset;
if (!pos.dir) {
pos.dir = '<-';
}
else {
return 'stop';
}
}
if (el.nodeType === Node.TEXT_NODE) {
if (pos.dir != '->')
pos.start += el.nodeValue.length;
if (pos.dir != '<-')
pos.end += el.nodeValue.length;
}
});
return pos;
}
function restore(pos) {
const s = getSelection();
let startNode, startOffset = 0;
let endNode, endOffset = 0;
if (!pos.dir)
pos.dir = '->';
if (pos.start < 0)
pos.start = 0;
if (pos.end < 0)
pos.end = 0;
// Flip start and end if the direction reversed
if (pos.dir == '<-') {
const { start, end } = pos;
pos.start = end;
pos.end = start;
}
let current = 0;
visit(editor, el => {
if (el.nodeType !== Node.TEXT_NODE)
return;
const len = (el.nodeValue || '').length;
if (current + len >= pos.start) {
if (!startNode) {
startNode = el;
startOffset = pos.start - current;
}
if (current + len >= pos.end) {
endNode = el;
endOffset = pos.end - current;
return 'stop';
}
}
current += len;
});
// If everything deleted place cursor at editor
if (!startNode)
startNode = editor;
if (!endNode)
endNode = editor;
// Flip back the selection
if (pos.dir == '<-') {
[startNode, startOffset, endNode, endOffset] = [endNode, endOffset, startNode, startOffset];
}
s.setBaseAndExtent(startNode, startOffset, endNode, endOffset);
}
function beforeCursor() {
const s = getSelection();
const r0 = s.getRangeAt(0);
const r = document.createRange();
r.selectNodeContents(editor);
r.setEnd(r0.startContainer, r0.startOffset);
return r.toString();
}
function afterCursor() {
const s = getSelection();
const r0 = s.getRangeAt(0);
const r = document.createRange();
r.selectNodeContents(editor);
r.setStart(r0.endContainer, r0.endOffset);
return r.toString();
}
function handleNewLine(event) {
if (event.key === 'Enter') {
const before = beforeCursor();
const after = afterCursor();
let [padding] = findPadding(before);
let newLinePadding = padding;
// If last symbol is "{" ident new line
// Allow user defines indent rule
if (options.indentOn.test(before)) {
newLinePadding += options.tab;
}
// Preserve padding
if (newLinePadding.length > 0) {
preventDefault(event);
event.stopPropagation();
insert('\n' + newLinePadding);
}
else {
firefoxNewLineFix(event);
}
// Place adjacent "}" on next line
if (newLinePadding !== padding && after[0] === '}') {
const pos = save();
insert('\n' + padding);
restore(pos);
}
}
}
function firefoxNewLineFix(event) {
// Firefox does not support plaintext-only mode
// and puts <div><br></div> on Enter. Let's help.
if (isFirefox && event.key === 'Enter') {
preventDefault(event);
event.stopPropagation();
if (afterCursor() == '') {
insert('\n ');
const pos = save();
pos.start = --pos.end;
restore(pos);
}
else {
insert('\n');
}
}
}
function handleSelfClosingCharacters(event) {
const open = `([{'"`;
const close = `)]}'"`;
const codeAfter = afterCursor();
const codeBefore = beforeCursor();
const escapeCharacter = codeBefore.substr(codeBefore.length - 1) === '\\';
const charAfter = codeAfter.substr(0, 1);
if (close.includes(event.key) && !escapeCharacter && charAfter === event.key) {
// We already have closing char next to cursor.
// Move one char to right.
const pos = save();
preventDefault(event);
pos.start = ++pos.end;
restore(pos);
}
else if (open.includes(event.key)
&& !escapeCharacter
&& (`"'`.includes(event.key) || ['', ' ', '\n'].includes(charAfter))) {
preventDefault(event);
const pos = save();
const wrapText = pos.start == pos.end ? '' : getSelection().toString();
const text = event.key + wrapText + close[open.indexOf(event.key)];
insert(text);
pos.start++;
pos.end++;
restore(pos);
}
}
function handleTabCharacters(event) {
if (event.key === 'Tab') {
preventDefault(event);
if (event.shiftKey) {
const before = beforeCursor();
let [padding, start,] = findPadding(before);
if (padding.length > 0) {
const pos = save();
// Remove full length tab or just remaining padding
const len = Math.min(options.tab.length, padding.length);
restore({ start, end: start + len });
document.execCommand('delete');
pos.start -= len;
pos.end -= len;
restore(pos);
}
}
else {
insert(options.tab);
}
}
}
function handleUndoRedo(event) {
if (isUndo(event)) {
preventDefault(event);
at--;
const record = history[at];
if (record) {
editor.innerHTML = record.html;
restore(record.pos);
}
if (at < 0)
at = 0;
}
if (isRedo(event)) {
preventDefault(event);
at++;
const record = history[at];
if (record) {
editor.innerHTML = record.html;
restore(record.pos);
}
if (at >= history.length)
at--;
}
}
function recordHistory() {
if (!focus)
return;
const html = editor.innerHTML;
const pos = save();
const lastRecord = history[at];
if (lastRecord) {
if (lastRecord.html === html
&& lastRecord.pos.start === pos.start
&& lastRecord.pos.end === pos.end)
return;
}
at++;
history[at] = { html, pos };
history.splice(at + 1);
const maxHistory = 300;
if (at > maxHistory) {
at = maxHistory;
history.splice(0, 1);
}
}
function handlePaste(event) {
preventDefault(event);
const text = (event.originalEvent || event)
.clipboardData
.getData('text/plain')
.replace(/\r/g, '');
const pos = save();
insert(text);
highlight(editor);
restore({ start: pos.start + text.length, end: pos.start + text.length });
}
function visit(editor, visitor) {
const queue = [];
if (editor.firstChild)
queue.push(editor.firstChild);
let el = queue.pop();
while (el) {
if (visitor(el) === 'stop')
break;
if (el.nextSibling)
queue.push(el.nextSibling);
if (el.firstChild)
queue.push(el.firstChild);
el = queue.pop();
}
}
function isCtrl(event) {
return event.metaKey || event.ctrlKey;
}
function isUndo(event) {
return isCtrl(event) && !event.shiftKey && event.key === 'z';
}
function isRedo(event) {
return isCtrl(event) && event.shiftKey && event.key === 'z';
}
function insert(text) {
text = text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
document.execCommand('insertHTML', false, text);
}
function debounce(cb, wait) {
let timeout = 0;
return (...args) => {
clearTimeout(timeout);
timeout = window.setTimeout(() => cb(...args), wait);
};
}
function findPadding(text) {
// Find beginning of previous line.
let i = text.length - 1;
while (i >= 0 && text[i] !== '\n')
i--;
i++;
// Find padding of the line.
let j = i;
while (j < text.length && /[ \t]/.test(text[j]))
j++;
return [text.substring(i, j) || '', i, j];
}
function toString() {
return editor.textContent || '';
}
function preventDefault(event) {
event.preventDefault();
}
function getSelection() {
var _a;
if (((_a = editor.parentNode) === null || _a === void 0 ? void 0 : _a.nodeType) == Node.DOCUMENT_FRAGMENT_NODE) {
return editor.parentNode.getSelection();
}
return window.getSelection();
}
return {
updateOptions(options) {
options = Object.assign(Object.assign({}, options), options);
},
updateCode(code) {
editor.textContent = code;
highlight(editor);
},
onUpdate(cb) {
callback = cb;
},
toString,
save,
restore,
recordHistory,
destroy() {
for (let [type, fn] of listeners) {
editor.removeEventListener(type, fn);
}
},
};
}

View File

@ -0,0 +1,60 @@
function withLineNumbers(highlight, options = {}) {
const opts = Object.assign({ class: "codejar-linenumbers", wrapClass: "codejar-wrap", width: "35px", backgroundColor: "rgba(128, 128, 128, 0.15)", color: "" }, options);
let lineNumbers;
return function (editor) {
highlight(editor);
if (!lineNumbers) {
lineNumbers = init(editor, opts);
editor.addEventListener("scroll", () => lineNumbers.style.top = `-${editor.scrollTop}px`);
}
const code = editor.textContent || "";
//const linesCount = code.replace(/\n+$/, "\n").split("\n").length + 1;
const linesCount = code.split("\n").length;
let text = "";
for (let i = 1; i < linesCount; i++) {
text += `${i}\n`;
}
lineNumbers.innerText = text;
};
}
function init(editor, opts) {
const css = getComputedStyle(editor);
const wrap = document.createElement("div");
wrap.className = opts.wrapClass;
wrap.style.position = "relative";
const gutter = document.createElement("div");
gutter.className = opts.class;
wrap.appendChild(gutter);
// Add own styles
gutter.style.position = "absolute";
gutter.style.top = "0px";
gutter.style.left = "0px";
gutter.style.bottom = "0px";
gutter.style.width = opts.width;
gutter.style.overflow = "hidden";
gutter.style.backgroundColor = opts.backgroundColor;
gutter.style.color = opts.color || css.color;
gutter.style.setProperty("mix-blend-mode", "difference");
// Copy editor styles
gutter.style.fontFamily = css.fontFamily;
gutter.style.fontSize = css.fontSize;
gutter.style.lineHeight = css.lineHeight;
gutter.style.paddingTop = css.paddingTop;
gutter.style.paddingLeft = css.paddingLeft;
gutter.style.borderTopLeftRadius = css.borderTopLeftRadius;
gutter.style.borderBottomLeftRadius = css.borderBottomLeftRadius;
// Add line numbers
const lineNumbers = document.createElement("div");
lineNumbers.style.position = "relative";
lineNumbers.style.top = "0px";
gutter.appendChild(lineNumbers);
// Tweak editor styles
editor.style.paddingLeft = `calc(${opts.width} + ${gutter.style.paddingLeft})`;
editor.style.whiteSpace = "pre";
// Swap editor with a wrap
editor.parentNode.insertBefore(wrap, editor);
wrap.appendChild(editor);
return lineNumbers;
}

View File

@ -0,0 +1,11 @@
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
Theme: GitHub Dark Dimmed
Description: Dark dimmed theme as seen on github.com
Author: github.com
Maintainer: @Hirse
Updated: 2021-05-15
Colors taken from GitHub's CSS
*/
.hljs{color:#adbac7;background:#22272e}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#f47067}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#dcbdfb}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#6cb6ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#96d0ff}.hljs-built_in,.hljs-symbol{color:#f69d50}.hljs-code,.hljs-comment,.hljs-formula{color:#768390}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#8ddb8c}.hljs-subst{color:#adbac7}.hljs-section{color:#316dca;font-weight:700}.hljs-bullet{color:#eac55f}.hljs-emphasis{color:#adbac7;font-style:italic}.hljs-strong{color:#adbac7;font-weight:700}.hljs-addition{color:#b4f1b4;background-color:#1b4721}.hljs-deletion{color:#ffd8d3;background-color:#78191b}

File diff suppressed because one or more lines are too long