<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>PyPy :: 标签 :: yafeng 的博客</title>
    <link>https://yafengabc.github.io/tags/pypy/index.html</link>
    <description></description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sat, 19 Sep 2026 16:30:07 +0800</lastBuildDate>
    <atom:link href="https://yafengabc.github.io/tags/pypy/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>MicroPython与Python速度对比</title>
      <link>https://yafengabc.github.io/cnblogs/p9034158/index.html</link>
      <pubDate>Mon, 14 May 2018 08:33:00 +0800</pubDate>
      <guid>https://yafengabc.github.io/cnblogs/p9034158/index.html</guid>
      <description>首先说明，micropython跟python是没有任何可比性的，python作为一种通用的语言，在扩展性上不是micropython能比的，比如大量的库，可以方便的用C语言加模块提升速度，有pypy这样的带JIT的解释器，micropython是适合于单片机的系统虽然可以用C写lib，但是需要重新编译整个固件，此外，micropython也缺乏加载本地代码的功能，比如加载C便宜的so库。所以不要试图用micropython代替python，这不是一个好主意，除非micropython支持的库满足你的使用了。&#xA;这篇文章主要是简单的对比这两个不同的实现的性能有何差别。&#xA;测试代码有两个，一个是一个大循环，一个是递归计算斐波那契数列，例子比较简单，代码如下：&#xA;try: import utime as time except: import time def bigloop(): s=0 for i in range(1000000000): s+=i def fib(n): if n==0: return 0 if n==1: return 1 return fib(n-1)+fib(n-2) t=time.time() bigloop() print(&#34;bigloop time:&#34;,time.time()-t) t=time.time() print(&#34;The 40th fibric is:&#34;,fib(40)) print(&#34;fibn time:&#34;,time.time()-t) 结果如下：&#xA;[yafeng@ArchV ~]$ python micromark.py bigloop time: 60.44254755973816 The 40th fibric is: 102334155 fibn time: 48.39746880531311 [yafeng@ArchV ~]$ micropython micromark.py bigloop time: 51.92846608161926 The 40th fibric is: 102334155 fibn time: 65.70703196525574 可以看到，效率基本是一样的，循环micropython稍快一点，递归cpython稍快一点，顺便贴一下pypy pypy3的结果： [yafeng@ArchV ~]$ pypy micromark.py (&#39;bigloop time:&#39;, 1.7053859233856201) (&#39;The 40th fibric is:&#39;, 102334155) (&#39;fibn time:&#39;, 7.795623064041138) [yafeng@ArchV ~]$ pypy3 micromark.py bigloop time: 1.2033970355987549 The 40th fibric is: 102334155 fibn time: 7.820451974868774 可以看到，pypy速都还是很明显的，喜闻乐见的是，pypy3甚至超过了pypy。</description>
    </item>
  </channel>
</rss>