.pyc & Python
.pyc & Python
Python bytecode / 字节码
Python compiles the .py files and saves it as .pyc files , so it can reference them in subsequent invocations.
The .pyc contain the compiled bytecode of Python source files, which is what the Python interpreter compiles the source to.
This code is then executed by Python's virtual machine . There's no harm in deleting them (.pyc), but they will save compilation time if you're doing lots of processing.
Python会编译.py文件并将其保存为.pyc文件,因此它可以在后续调用中引用它们。
.pyc包含Python源文件的已编译字节码,这是Python解释器将源代码编译到的字节码。
然后,此代码由Python的虚拟机执行。删除它们(.pyc)没有什么害处,但是如果您要进行大量处理,它们将节省编译时间。
test.py
# coding: utf8
__author__ = 'xgqfrms'
__editor__ = 'vscode'
__version__ = '1.0.1'
__copyright__ = """
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
"""
class Test(object):
def sum(a, b):
return a + b
test.pyc
�
�*_c�����������@���s2���d��Z��d�Z�d�Z�d�Z�d�e�f�d�������YZ�d�S(���t���xgqfrmst���vscodes���1.0.1s@���
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
t���Testc�����������B���s���e��Z�d�����Z�RS(���c���������C���s���|��|�S(���N(����(���t���at���b(����(����s@���/Users/xgqfrms-mbp/Documents/GitHub/Python/spider/spider/test.pyt���sum
���s����(���t���__name__t
���__module__R���(����(����(����s@���/Users/xgqfrms-mbp/Documents/GitHub/Python/spider/spider/test.pyR��� ���s���N(���t
���__author__t
���__editor__t���__version__t
���__copyright__t���objectR���(����(����(����s@���/Users/xgqfrms-mbp/Documents/GitHub/Python/spider/spider/test.pyt���<module>���s���
env
声明为可执行文件, 不会编译成字节码
#! /usr/bin/env python
# 声明为可执行文件
# coding: utf8
__author__ = 'xgqfrms'
__editor__ = 'vscode'
__version__ = '1.0.1'
__copyright__ = """
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
"""
class Test(object):
def sum(a, b):
return a + b
refs
http://net-informations.com/python/iq/pyc.htm
https://stackoverflow.com/questions/2998215/if-python-is-interpreted-what-are-pyc-files
https://en.wikipedia.org/wiki/Pyc
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13443217.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2019-08-05 Dart & basic
2019-08-05 Flutter & package & publish
2019-08-05 Flutter & Components & Widgets
2019-08-05 Flutter & Network & Storage
2019-08-05 Flutter & Animation
2019-08-05 Flutter & layout
2019-08-05 Flutter 学习路径