.py

python文本源码文件,也可以用python.exe直接运行

.pyw

也是python的文本源码文件,但是默认由pythonw.exe打开,而且不显示命令行窗口,带GUI的python代码可以使用这个,比如自带的idle.pyw

.pyc

由.py文件编译生成的二进制文件,执行速度可能会快点,但是相对于.py文件体积上的减小并不是很明显,还有个缺点是不同的python版本生成的.pyc文件不通用!

.pyo

这个也是由.py编译生成的二进制文件,暂时理解为相对于.pyc优化了一下的东西

.pyd

说是什么python的动态链接库文件,不太懂,搞清楚了再来补充

另外,贴一下python自带的chm文件中关于“编译后的模块”的说明:

6.1.3. “Compiled” Python files

As an important speed-up of the start-up time for short programs that use a lot of standard modules, if a file called spam.pyc exists in the directory where spam.py is found, this is assumed to contain an already-“byte-compiled” version of the module spam. The modification time of the version of spam.py used to create spam.pyc is recorded in spam.pyc, and the .pyc file is ignored if these don’t match.

Normally, you don’t need to do anything to create the spam.pyc file. Whenever spam.py is successfully compiled, an attempt is made to write the compiled version to spam.pyc. It is not an error if this attempt fails; if for any reason the file is not written completely, the resulting spam.pyc file will be recognized as invalid and thus ignored later. The contents of the spam.pyc file are platform independent, so a Python module directory can be shared by machines of different architectures.

Some tips for experts:

When the Python interpreter is invoked with the -O flag, optimized code is generated and stored in .pyo files. The optimizer currently doesn’t help much; it only removes assert statements. When -O is used, all bytecode is optimized; .pyc files are ignored and .py files are compiled to optimized bytecode.

Passing two -O flags to the Python interpreter (-OO) will cause the bytecode compiler to perform optimizations that could in some rare cases result in malfunctioning programs. Currently only __doc__ strings are removed from the bytecode, resulting in more compact .pyo files. Since some programs may rely on having these available, you should only use this option if you know what you’re doing.

A program doesn’t run any faster when it is read from a .pyc or .pyo file than when it is read from a .py file; the only thing that’s faster about .pyc or .pyo files is the speed with which they are loaded.

When a script is run by giving its name on the command line, the bytecode for the script is never written to a .pyc or .pyo file. Thus, the startup time of a script may be reduced by moving most of its code to a module and having a small bootstrap script that imports that module. It is also possible to name a .pyc or .pyo file directly on the command line.

It is possible to have a file called spam.pyc (or spam.pyo when -O is used) without a file spam.py for the same module. This can be used to distribute a library of Python code in a form that is moderately hard to reverse engineer.

The module compileall can create .pyc files (or .pyo files when -O is used) for all modules in a directory.

记录一下跟Python有关的几个拓展名的更多相关文章

  1. 记录遇到的Python陷阱和注意点

    最近使用Python的过程中遇到了一些坑,例如用datetime.datetime.now()这个可变对象作为函数的默认参数,模块循环依赖等等. 在此记录一下,方便以后查询和补充. 避免可变对象作为默 ...

  2. 记录两个python的小问题

    使用python也前前后后也一个月的样子,记录两个一直没注意的问题. 1. 元组的使用(拼接字符串) 直接看下面的代码: >>> kel = 'some','strings' > ...

  3. 记录我的 python 学习历程-Day02-while 循环/格式化输出/运算符/编码的初识

    一.流程控制之--while 循环 循环就是重复做同一件事,它可以终止当前循环,也可以跳出这一次循环,继续下一次循环. 基本结构(基本循环) while 条件: 循环体 示例 # 这是一个模拟音乐循环 ...

  4. 记录我的 python 学习历程-Day06 is id == / 代码块 / 集合 / 深浅拷贝

    一.is == id 用法 在Python中,id是内存地址, 你只要创建一个数据(对象)那么就会在内存中开辟一个空间,将这个数据临时加载到内存中,这个空间有一个唯一标识,就好比是身份证号,标识这个空 ...

  5. 首篇-记录自己学习python之路!

    对于自己学习python的目的比较明确——爬虫和量化. 目前找了一些资源进行学习,先进行量化方面的学习,爬虫滞后.目前的目标是“180天掌握尽可能多的量化能力”! 以后定时发送自己学习思考内容以作自己 ...

  6. 记录我的 python 学习历程-Day12 生成器/推导式/内置函数Ⅰ

    一.生成器 初识生成器 生成器的本质就是迭代器,在python社区中,大多数时候都把迭代器和生成器是做同一个概念. 唯一的不同就是: 迭代器都是Python给你提供的已经写好的工具或者通过数据转化得来 ...

  7. 记录我的 python 学习历程-Day13 匿名函数、内置函数 II、闭包

    一.匿名函数 以后面试或者工作中经常用匿名函数 lambda,也叫一句话函数. 课上练习: # 正常函数: def func(a, b): return a + b print(func(4, 6)) ...

  8. 记录今天学习python中for与while循环针对break和continue的用法

    python中有两个主要的循环for与while,其中针对这两个循环有两种不同的中断用法break与continue. 首先先看下面的循环代码: 1: for i in range(10):#变量i带 ...

  9. 开发记录_自学Python写爬虫程序爬取csdn个人博客信息

    每天刷开csdn的博客,看到一整个页面,其实对我而言,我只想看看访问量有没有上涨而已... 于是萌生了一个想法: 想写一个爬虫程序把csdn博客上边的访问量和评论数都爬下来. 打算通过网络各种搜集资料 ...

随机推荐

  1. 【Unity3D】生成工程报错解决—UnityEditor.HostView:OnGUI() Error building Player: Couldn't build player because of unsupported data on target platform.

    错误 错误1:An asset is marked as dont save, but is included in the build: unityEditor.HostView:OnGUI() 错 ...

  2. 【转】自定义UITableViewCell控件阻挡回调不到didSelectRowAtIndexPath的解决办法

    原文网址:http://blog.talisk.cn/blog/2015/09/01/uitableview-didselectrowatindexpath-cannot-be-called-tips ...

  3. 【转】./a.out 2>&1 > outfile

    原文网址:http://www.cnblogs.com/zhaoyl/archive/2012/10/22/2733418.html APUE 3.5关于重定向有个容易迷惑人的问题: ./a.out ...

  4. IE下JS接受ActiveX控件方法

    1.常规写法 <SCRIPT type="text/javascript" FOR="activexID" EVENT="onXXXevent( ...

  5. 消息提示和消息推送插件toastr

    http://www.jq22.com/yanshi476 比较棒的消息提示和消息推送插件toastr function myIntervalshow() { // showPopup1(300, 1 ...

  6. redis配置实例及redis.conf详细说明

    一.配置实例 1.redis修改持久化路径.日志路径.清缓存 redis修改持久化路径和日志路径 vim  redis.conf logfile /data/redis_cache/logs/redi ...

  7. codeforces 682C Alyona and the Tree DFS

    这个题就是在dfs的过程中记录到根的前缀和,以及前缀和的最小值 #include <cstdio> #include <iostream> #include <ctime ...

  8. 设置layoutControl1 中的 控件的 focus

    设置 layoutControl1 中的layoutControl EnableAutoTabOrder 为 false; this.layoutControl1.ActiveControl = th ...

  9. DataGird导出EXCEL的几个方法

    DataGird导出EXCEL的几个方法(WebControl) using System;using System.Data;using System.Text;using System.Web;u ...

  10. ORA-15063: ASM discovered an insufficient number of disks for diskgroup "ASM,KEL"

    在启动ASM的时候报错,报错如下: SQL> startup ASM instance started Total System Global Area 130023424 bytes Fixe ...