index.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <!DOCTYPE html>
  2. <html lang="en" class="h-full">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <meta name="color-scheme" content="light dark">
  7. <meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="4.3.0.827133044009">
  8. <!-- See retype.com -->
  9. <meta name="generator" content="Retype 4.3.0">
  10. <!-- Primary Meta Tags -->
  11. <title>Performance | Portable Python 3.x Interpreter in Modern C</title>
  12. <meta name="title" content="Performance | Portable Python 3.x Interpreter in Modern C">
  13. <meta name="description" content="Currently, pkpy is as fast as cpython 3.9. Performance results for cpython 3.9 are applicable to for pkpy.">
  14. <!-- Canonical -->
  15. <link rel="canonical" href="https://pocketpy.dev/performance/">
  16. <!-- Open Graph -->
  17. <meta property="og:type" content="website">
  18. <meta property="og:url" content="https://pocketpy.dev/performance/">
  19. <meta property="og:title" content="Performance | Portable Python 3.x Interpreter in Modern C">
  20. <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.">
  21. <meta property="og:site_name" content="pocketpy">
  22. <meta property="og:locale" content="en_US">
  23. <!-- Twitter -->
  24. <meta name="twitter:card" content="summary_large_image">
  25. <meta name="twitter:url" content="https://pocketpy.dev/performance/">
  26. <meta name="twitter:title" content="Performance | Portable Python 3.x Interpreter in Modern C">
  27. <meta name="twitter:description" content="Currently, pkpy is as fast as cpython 3.9. Performance results for cpython 3.9 are applicable to for pkpy.">
  28. <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>
  29. <link id="retype-favicon" rel="icon" href="../static/logo.png" />
  30. <link href="../resources/css/retype.css?v=4.3.0.827133044009" rel="stylesheet">
  31. <script data-cfasync="false" src="../resources/js/config.js?v=4.3.0.827133044009" data-turbo-eval="false" defer></script>
  32. <script data-cfasync="false" src="../resources/js/retype.js?v=4.3.0" data-turbo-eval="false" defer></script>
  33. <script id="lunr-js" data-cfasync="false" src="../resources/js/lunr.js?v=4.3.0.827133044009" data-turbo-eval="false" defer></script>
  34. <script id="prism-js" data-cfasync="false" src="../resources/js/prism.js?v=4.3.0.827133044009" defer></script>
  35. </head>
  36. <body>
  37. <div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
  38. <div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
  39. <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">
  40. <div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
  41. <!-- Mobile menu button skeleton -->
  42. <button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-hidden 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>
  43. <div v-cloak id="retype-sidebar-left-toggle-button"></div>
  44. <!-- Logo -->
  45. <div class="flex items-center justify-between h-full py-2 md:w-75">
  46. <div class="flex items-center px-2 md:px-6">
  47. <a id="retype-branding-logo" href="https://pocketpy.dev/" class="flex items-center leading-snug text-2xl">
  48. <span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
  49. <img class="max-h-10 dark:hidden md:inline-block" src="../static/logo.png" alt="" width="512" height="512">
  50. <img class="max-h-10 hidden dark:inline-block" src="../static/logo.png" alt="" width="512" height="512">
  51. </span>
  52. <span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
  53. </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.8</span>
  54. </div>
  55. <span class="hidden h-8 border-r md:inline-block border-base-border"></span>
  56. </div>
  57. <div class="flex justify-between md:grow">
  58. <!-- Top Nav -->
  59. <nav id="retype-header-nav" class="hidden md:flex">
  60. <ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
  61. <li class="mr-6">
  62. <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 hover:text-header-text-hover" href="">
  63. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  64. <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"/>
  65. </svg>
  66. <span>Home</span>
  67. </a>
  68. </li>
  69. <li class="mr-6">
  70. <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 hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
  71. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  72. <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"/>
  73. </svg>
  74. <span>Live Demo</span>
  75. </a>
  76. </li>
  77. <li class="mr-6">
  78. <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 hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
  79. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  80. <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"/>
  81. </svg>
  82. <span>Live Examples</span>
  83. </a>
  84. </li>
  85. <li class="mr-6">
  86. <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 hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
  87. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  88. <path d="M10.303 16.652c-2.837-.344-4.835-2.385-4.835-5.028 0-1.074.387-2.235 1.031-3.008-.279-.709-.236-2.214.086-2.837.86-.107 2.02.344 2.708.967.816-.258 1.676-.386 2.728-.386 1.053 0 1.913.128 2.686.365.666-.602 1.848-1.053 2.708-.946.3.581.344 2.085.064 2.815.688.817 1.053 1.913 1.053 3.03 0 2.643-1.998 4.641-4.877 5.006.73.473 1.224 1.504 1.224 2.686v2.235c0 .644.537 1.01 1.182.752 3.889-1.483 6.94-5.372 6.94-10.185 0-6.081-4.942-11.044-11.022-11.044-6.081 0-10.98 4.963-10.98 11.044a10.84 10.84 0 0 0 7.112 10.206c.58.215 1.139-.172 1.139-.752v-1.719a2.768 2.768 0 0 1-1.032.215c-1.418 0-2.256-.773-2.857-2.213-.237-.58-.495-.924-.989-.988-.258-.022-.344-.129-.344-.258 0-.258.43-.451.86-.451.623 0 1.16.386 1.719 1.181.43.623.881.903 1.418.903.537 0 .881-.194 1.375-.688.365-.365.645-.687.903-.902Z"/>
  89. </svg>
  90. <span>Github</span>
  91. </a>
  92. </li>
  93. <li class="mr-6">
  94. <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 hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
  95. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  96. <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"/>
  97. </svg>
  98. <span>Discord</span>
  99. </a>
  100. </li>
  101. </ul>
  102. </nav>
  103. <div v-cloak class="flex justify-end grow">
  104. <div id="retype-mobile-search-button"></div>
  105. <doc-search-desktop></doc-search-desktop>
  106. <doc-theme-switch class="lg:ml-2"></doc-theme-switch>
  107. <doc-history></doc-history>
  108. </div>
  109. </div>
  110. </div>
  111. </header>
  112. <div id="retype-container" class="container relative flex bg-white">
  113. <!-- Sidebar Skeleton -->
  114. <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">
  115. <div class="flex items-center h-16 px-6">
  116. <input id="retype-filter-input-mock" class="w-full h-10 pl-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded-lg shadow-none md:text-sm hover:border-filter-border-hover focus:outline-hidden focus:border-filter-border-focus placeholder-filter-placeholder" type="text">
  117. </div>
  118. <div class="pl-6 mt-1 mb-4">
  119. <div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  120. <div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  121. <div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  122. <div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  123. <div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  124. <div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  125. </div>
  126. <div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
  127. <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">
  128. <span class="text-xs whitespace-nowrap">Powered by</span>
  129. <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>
  130. </a>
  131. </div>
  132. </div>
  133. <!-- Sidebar component -->
  134. <doc-sidebar v-cloak>
  135. <template #sidebar-footer>
  136. <div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
  137. <div class="py-3 px-6 md:hidden border-b dark:border-base-border">
  138. <nav>
  139. <ul class="flex flex-wrap justify-center items-center">
  140. <li class="mr-6">
  141. <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 hover:text-header-text-hover" href="">
  142. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  143. <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"/>
  144. </svg>
  145. <span>Home</span>
  146. </a>
  147. </li>
  148. <li class="mr-6">
  149. <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 hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
  150. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  151. <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"/>
  152. </svg>
  153. <span>Live Demo</span>
  154. </a>
  155. </li>
  156. <li class="mr-6">
  157. <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 hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
  158. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  159. <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"/>
  160. </svg>
  161. <span>Live Examples</span>
  162. </a>
  163. </li>
  164. <li class="mr-6">
  165. <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 hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
  166. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  167. <path d="M10.303 16.652c-2.837-.344-4.835-2.385-4.835-5.028 0-1.074.387-2.235 1.031-3.008-.279-.709-.236-2.214.086-2.837.86-.107 2.02.344 2.708.967.816-.258 1.676-.386 2.728-.386 1.053 0 1.913.128 2.686.365.666-.602 1.848-1.053 2.708-.946.3.581.344 2.085.064 2.815.688.817 1.053 1.913 1.053 3.03 0 2.643-1.998 4.641-4.877 5.006.73.473 1.224 1.504 1.224 2.686v2.235c0 .644.537 1.01 1.182.752 3.889-1.483 6.94-5.372 6.94-10.185 0-6.081-4.942-11.044-11.022-11.044-6.081 0-10.98 4.963-10.98 11.044a10.84 10.84 0 0 0 7.112 10.206c.58.215 1.139-.172 1.139-.752v-1.719a2.768 2.768 0 0 1-1.032.215c-1.418 0-2.256-.773-2.857-2.213-.237-.58-.495-.924-.989-.988-.258-.022-.344-.129-.344-.258 0-.258.43-.451.86-.451.623 0 1.16.386 1.719 1.181.43.623.881.903 1.418.903.537 0 .881-.194 1.375-.688.365-.365.645-.687.903-.902Z"/>
  168. </svg>
  169. <span>Github</span>
  170. </a>
  171. </li>
  172. <li class="mr-6">
  173. <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 hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
  174. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1.5" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
  175. <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"/>
  176. </svg>
  177. <span>Discord</span>
  178. </a>
  179. </li>
  180. </ul>
  181. </nav>
  182. </div>
  183. <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">
  184. <span class="text-xs whitespace-nowrap">Powered by</span>
  185. <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>
  186. </a>
  187. </div>
  188. </template>
  189. </doc-sidebar>
  190. <div class="grow min-w-0 bg-body-bg">
  191. <!-- Render "toolbar" template here on api pages --><!-- Render page content -->
  192. <div class="flex">
  193. <div id="retype-main" class="min-w-0 p-4 grow md:px-16">
  194. <main class="relative pb-12 lg:pt-2">
  195. <div class="retype-markdown" id="retype-content">
  196. <!-- Rendered if sidebar right is enabled -->
  197. <div id="retype-sidebar-right-toggle"></div>
  198. <!-- Page content -->
  199. <h1 id="performance">Performance</h1>
  200. <p>Currently, pkpy is as fast as cpython 3.9.
  201. Performance results for cpython 3.9 are applicable to for pkpy.</p>
  202. <p>Here is a benchmark result of <code translate="no" v-pre>v1.2.6</code>.
  203. Files are located in <code translate="no" v-pre>benchmarks/</code>.</p>
  204. <h2 id="win32-64-bit-cpy39">win32 64-bit cpy39</h2>
  205. <div id="win32-64-bit-cpy39-code-1" class="codeblock-wrapper"><doc-codeblock>
  206. <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)]
  207. System: 64-bit
  208. Testing directory: benchmarks/
  209. &gt; benchmarks/fib.py
  210. cpython: 0.986091s (100%)
  211. pocketpy: 0.985427s (99.93%)
  212. &gt; benchmarks/loop_0.py
  213. cpython: 0.515685s (100%)
  214. pocketpy: 0.344132s (66.73%)
  215. &gt; benchmarks/loop_1.py
  216. cpython: 0.938407s (100%)
  217. pocketpy: 0.595634s (63.47%)
  218. &gt; benchmarks/loop_2.py
  219. cpython: 1.188671s (100%)
  220. pocketpy: 0.735259s (61.86%)
  221. &gt; benchmarks/loop_3.py
  222. cpython: 4.957218s (100%)
  223. pocketpy: 2.314210s (46.68%)
  224. &gt; benchmarks/primes.py
  225. cpython: 9.146332s (100%)
  226. pocketpy: 8.507227s (93.01%)
  227. &gt; benchmarks/recursive.py
  228. cpython: 0.044789s (100%)
  229. pocketpy: 0.031252s (69.78%)
  230. &gt; benchmarks/simple.py
  231. cpython: 0.516624s (100%)
  232. pocketpy: 0.453159s (87.72%)
  233. &gt; benchmarks/sort.py
  234. cpython: 0.929597s (100%)
  235. pocketpy: 0.406802s (43.76%)
  236. &gt; benchmarks/sum.py
  237. cpython: 0.047151s (100%)
  238. pocketpy: 0.031266s (66.31%)
  239. ALL TESTS PASSED</code></pre>
  240. </doc-codeblock></div>
  241. <h2 id="linux-64-bit-cpy38">linux 64-bit cpy38</h2>
  242. <div id="linux-64-bit-cpy38-code-1" class="codeblock-wrapper"><doc-codeblock>
  243. <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]
  244. System: 64-bit
  245. Testing directory: benchmarks/
  246. &gt; benchmarks/fib.py
  247. cpython: 0.739547s (100%)
  248. pocketpy: 0.613591s (82.97%)
  249. &gt; benchmarks/loop_0.py
  250. cpython: 0.356003s (100%)
  251. pocketpy: 0.224396s (63.03%)
  252. &gt; benchmarks/loop_1.py
  253. cpython: 0.661924s (100%)
  254. pocketpy: 0.446577s (67.47%)
  255. &gt; benchmarks/loop_2.py
  256. cpython: 0.937243s (100%)
  257. pocketpy: 0.514324s (54.88%)
  258. &gt; benchmarks/loop_3.py
  259. cpython: 3.671752s (100%)
  260. pocketpy: 1.876151s (51.10%)
  261. &gt; benchmarks/primes.py
  262. cpython: 7.293947s (100%)
  263. pocketpy: 5.427518s (74.41%)
  264. &gt; benchmarks/recursive.py
  265. cpython: 0.021559s (100%)
  266. pocketpy: 0.010227s (47.44%)
  267. &gt; benchmarks/simple.py
  268. cpython: 0.408654s (100%)
  269. pocketpy: 0.265084s (64.87%)
  270. &gt; benchmarks/sort.py
  271. cpython: 0.372539s (100%)
  272. pocketpy: 0.243566s (65.38%)
  273. &gt; benchmarks/sum.py
  274. cpython: 0.021242s (100%)
  275. pocketpy: 0.010113s (47.61%)
  276. ALL TESTS PASSED</code></pre>
  277. </doc-codeblock></div>
  278. <h2 id="linux-32-bit-cpy39">linux 32-bit cpy39</h2>
  279. <div id="linux-32-bit-cpy39-code-1" class="codeblock-wrapper"><doc-codeblock>
  280. <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]
  281. System: 32-bit
  282. Testing directory: benchmarks/
  283. &gt; benchmarks/fib.py
  284. cpython: 1.967908s (100%)
  285. pocketpy: 0.960947s (48.83%)
  286. &gt; benchmarks/loop_0.py
  287. cpython: 1.063461s (100%)
  288. pocketpy: 0.396626s (37.30%)
  289. &gt; benchmarks/loop_1.py
  290. cpython: 1.563821s (100%)
  291. pocketpy: 0.639663s (40.90%)
  292. &gt; benchmarks/loop_2.py
  293. cpython: 2.626848s (100%)
  294. pocketpy: 0.757444s (28.83%)
  295. &gt; benchmarks/loop_3.py
  296. cpython: 13.428345s (100%)
  297. pocketpy: 2.852351s (21.24%)
  298. &gt; benchmarks/primes.py
  299. cpython: 18.174904s (100%)
  300. pocketpy: 8.423515s (46.35%)
  301. &gt; benchmarks/recursive.py
  302. cpython: 0.025673s (100%)
  303. pocketpy: 0.012470s (48.57%)
  304. &gt; benchmarks/simple.py
  305. cpython: 1.042090s (100%)
  306. pocketpy: 0.480013s (46.06%)
  307. &gt; benchmarks/sort.py
  308. cpython: 0.989279s (100%)
  309. pocketpy: 0.379171s (38.33%)
  310. &gt; benchmarks/sum.py
  311. cpython: 0.024227s (100%)
  312. pocketpy: 0.012477s (51.50%)
  313. ALL TESTS PASSED</code></pre>
  314. </doc-codeblock></div>
  315. <p>See <a href="https://github.com/pocketpy/pocketpy/actions/runs/6511071423/job/17686074263">actions/runs</a>.</p>
  316. <h2 id="primes-benchmarks">Primes benchmarks</h2>
  317. <p>These are the results of the primes benchmark on Intel i5-12400F, WSL (Ubuntu 20.04 LTS).</p>
  318. <div class="table-wrapper scrollbar overflow-hidden">
  319. <table class="comfortable">
  320. <thead>
  321. <tr>
  322. <th>name</th>
  323. <th>version</th>
  324. <th>time</th>
  325. <th>file</th>
  326. </tr>
  327. </thead>
  328. <tbody>
  329. <tr>
  330. <td>c++</td>
  331. <td>gnu++11</td>
  332. <td><code translate="no" v-pre>0.104s ■□□□□□□□□□□□□□□□</code></td>
  333. <td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.cpp">benchmarks/primes.cpp</a></td>
  334. </tr>
  335. <tr>
  336. <td>lua</td>
  337. <td>5.3.3</td>
  338. <td><code translate="no" v-pre>1.576s ■■■■■■■■■□□□□□□□</code></td>
  339. <td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.lua">benchmarks/primes.lua</a></td>
  340. </tr>
  341. <tr>
  342. <td>pkpy</td>
  343. <td>1.2.7</td>
  344. <td><code translate="no" v-pre>2.385s ■■■■■■■■■■■■■□□□</code></td>
  345. <td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.py">benchmarks/primes.py</a></td>
  346. </tr>
  347. <tr>
  348. <td>cpython</td>
  349. <td>3.8.10</td>
  350. <td><code translate="no" v-pre>2.871s ■■■■■■■■■■■■■■■■</code></td>
  351. <td><a href="https://github.com/pocketpy/pocketpy/blob/9481d653b60b81f4590a4d48f2be496f6962261e/benchmarks/primes.py">benchmarks/primes.py</a></td>
  352. </tr>
  353. </tbody>
  354. </table>
  355. </div>
  356. <div id="primes-benchmarks-code-1" class="codeblock-wrapper"><doc-codeblock>
  357. <pre translate="no" class="language-bash"><code v-pre class="language-bash">$ time lua benchmarks/primes.lua
  358. real 0m1.576s
  359. user 0m1.514s
  360. sys 0m0.060s
  361. $ time ./main benchmarks/primes.py
  362. real 0m2.385s
  363. user 0m2.247s
  364. sys 0m0.100s
  365. $ time python benchmarks/primes.py
  366. real 0m2.871s
  367. user 0m2.798s
  368. sys 0m0.060s</code></pre>
  369. </doc-codeblock></div>
  370. <!-- Required only on API pages -->
  371. <doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
  372. </div>
  373. <footer id="retype-content-footer" class="clear-both">
  374. <nav id="retype-nextprev" class="print:hidden flex mt-14">
  375. <div class="w-1/2">
  376. <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/">
  377. <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>
  378. <span>
  379. <span class="block text-xs font-normal text-base-text-muted">Previous</span>
  380. <span class="block mt-1">Coding Style Guide</span>
  381. </span>
  382. </a>
  383. </div>
  384. <div class="w-1/2">
  385. <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/">
  386. <span>
  387. <span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
  388. <span class="block mt-1">License</span>
  389. </span>
  390. <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>
  391. </a>
  392. </div>
  393. </nav>
  394. </footer>
  395. </main>
  396. <div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
  397. <footer class="flex flex-wrap items-center justify-between print:justify-center">
  398. <div id="retype-footer-links" class="print:hidden">
  399. <ul class="flex flex-wrap items-center text-sm">
  400. </ul>
  401. </div>
  402. <div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link text-sm leading-relaxed"><p>© Copyright 2026 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
  403. </footer>
  404. </div>
  405. </div>
  406. <!-- Rendered if sidebar right is enabled -->
  407. <!-- Sidebar right skeleton-->
  408. <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:translate-x-0 sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
  409. <div class="pl-5">
  410. <div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  411. <div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  412. <div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  413. </div>
  414. </div>
  415. <!-- User should be able to hide sidebar right -->
  416. <doc-sidebar-right v-cloak></doc-sidebar-right>
  417. </div>
  418. </div>
  419. </div>
  420. <doc-search-mobile></doc-search-mobile>
  421. <doc-back-to-top></doc-back-to-top>
  422. </div>
  423. <div id="retype-overlay-target"></div>
  424. <script data-cfasync="false">window.__DOCS__ = { "title": "Performance", level: 1, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
  425. </body>
  426. </html>