下载  >  开发技术  >  Python  > Python官方参考文档PDF合并版

Python官方参考文档PDF合并版 评分

Python 3.7.3参考文档PDF英文版,该文档包含了Python官方文档的各各方面,包括Python语言参考、HOWTOs, 标准库、Python/C扩展, 模块安装等等,是python开发必备参考文档
6 C API Changes 24 7 Build Changes 25 8 Optimizations 25 9 Other CPython Implementation Changes 27 10 Deprecated Python Behavior 27 11 Deprecated Python modules, functions and method 27 11.2 asencio ...27 11. 3 collections 11.4 dbm 11.5 enum 28 11.6 gettext 11.7 iInportlil 11. 8 locale 28 11.9 mappath 11. 10threading 11.socket 11.12ssl 29 11. 13sunau 11.14sys 11.lwave 12 Deprecated functions and types of the C API 29 13 Platform Support Removals 29 14 API and Feature removals 30 15 Module removals 30 16 Windows-only Changes 31 17 Porting to Python 3.7 31 17.1 Changes in Python Behavior 31 17.2 Changes in the Python API 31 17.3 Changes in the C API 17.4 CPython bytecode changes 17.5 Windows-only Changes 34 17.6 Other CPython implementation changes 18 Notable changes in Python 3. 7.1 34 19 Notable changes in Python 3.7.2 35 Index 36 Editor Elvis Pranskevichus <elvis @magic.io> This article explains the new features in Python 3.7, compared to 3.6. Python 3. 7 was released on June 27 2018. For full details, see the changelog 1 Summary Release Highlights New syntax features PEP 563, postponed evaluation of type annotations Backwards incompatible syntax changes async and await are now reserved keywords New library modules: contextvars: PEP 567- Context variables dataclasses: PEP 557- Data Classes importin resources New built-in features PEP 553, the new breakpoint function Python data model improvements PEP 562 customization of access to module attributes PEP 560, core support for typing module and generic types the ilnsertiol-order preservation nlature of dict objects has been declared to be all official part of the Python language spec Significant improvements in the standard library The asyncio module has received new features, significant usability and performance improvements The time module gaincd support for functions with nanosecond resolution CPython implementation improvements Avoiding the use of AsciI as a default text encoding PEP 538, legacy C locale coercion PEP 540, forced UTF-8 runtime mode PEP 552, deterministic. py cs the nmea development runtime mode PEP 565, improved DeprecationWarning handling C API improvements PEP 539, new C API for thread-local storage Documentation improvements PEP 545, Python documentation translations New documentation translations: Japanese, French and Korean 4 This release features notable performance improvements in many areas. The Optimizations section lists them in detail For a list of changes that may affect compatibility with previous Python rolcascs plcasc refer to the Porting to Python 3.1 section 2 New Features 2.1 PEP 563: Postponed Evaluation of Annotations The advent, of type hints in Python uncovered two glaring usability issues wit h the functionality of a.nnota- tions added in pep 3107 and refined further in PEP 526 annotations could only use names which were already available in the current scope, in other words t hey didnt support forward references of any kind; and annotating sourcc codc had adverse cffccts on startup timc of Python programs Both of these issues are fixed by postponing the evaluation of annotations. Instead of compiling code which executes expressions in annotations at their definition time, the compiler stores the annotation in a string form equivalent to the ast of the expression in question. If needed, annotations can be resolved at runtime using typing. get_type_hints(. In the common case where this is not required, the annotations are cheaper to store(since short strings are interned by the interpreter) and make startup time faster Usability-wise, annotations now support forward references, making the following syntax valid ass C @classmethod def from_string(cls, source: str)->C: def validate_b(self, obj: B)->bool: class b Since this change breaks compatibility, the new behavior needs to be enabled on a per-module basis in Python 3. 7 using a future import from __future__ import annotations It will become the default in Python 4.0 Scc also: PEP 563- Postponed evaluation of annotations PEP written and implemented by Lukasz langa 2.2 PEP 538: Legacy C Locale Coercion An ongoing challenge within the Python 3 series has been determining a sensible default strategy for handling the "7-bit ASCII text encoding assumption currently implied by the use of the default c or PosiX locale on non-Windows platforms 5 PEP 538 updates the default interpreter command line interface to automatically coerce that locale to an available utf-8 based locale as described in the documentation of the new pythoncoerceclocale en vironment variable. Automatically setting LC_ cTYpe this way means that both the core interpreter and locale-aware C extensions(such as readline)will assume the use of UTF-8 as the default text encoding rather than ASCII The platform support definition in PEP ll has also been updated to limit full text handling support to suitably configured non-ASCii based locales As part of this change, the default, error handler for stdin and stdout is now surrogateescape (rather than strict)when using any of the defined coercion target locales(currently C UTF-8, C utf8, and UTF-8) The default error handler for stderr continues to be backslashreplace, regardless of locale Locale coercion is silent by default, but to assist in debugging potentially locale related integration problems explicit warnings (emitted directly on stderr) can be requested by setting PYTHONCOERCECLOCALE-warn This setting will also cause the Python runtime to emit a warning if the legacy C locale remains active when the core interpreter is initialized Whilc PEP 538's locale coercion has the bcncfit of also affecting extension modules(such as GNt readline as well as child processes (including those running non-Python applications and older versions of Python) it has the downside of requiring that a suitable target locale be present on the running system. To better handle the case where no suitable target locale is available(as occurs on RHEL CentOS 7, for example) Python 3. 7 also implements PEP 540: Forced UTF-8 Runtime Mode See also PEP 538- Cocrcing the legacy C locale to a UTF-8 bascd locale PEP written and implcmcntcd by Nick Coghlan 2.3 PEP 540: Forced UTF-8 Runtime mode The new -X utf8 command line option and PYThONUTF8 environment variable can be used to enable the CPython UTF-8 mode When in UTF-8 mode. CPvthon ignores the locale settings, and uses the UTF-8 encoding by default. The error handlers for sys. stdin and sys. stdout streams are set to surrogateescape The forced UTF-8 mode can be used to change the text handling behavior in an embedded Python interpreter without changing the locale settings of an embedding application While PEP 540s UTF-8 mode has the benefit of working regardless of which locales are available on the running systcm. it has the downside of having no cffcct on extension modules(such as GNU readline), child processes running non-Python applications, and child processes running older versions of Python. To reduce the risk of corrupt ing text data. when communicating with such components, Python 3.7 also implements PEP 540: Forced UTF-8 Runtime Mode The UTF-8 Inode is enabled by default when the locale is C or POSIX, and the PEP 538 locale coercion feature fails to change it to a UTF-8 based alternative(whether that failure is due to PYTHONCOERCECLOCALE=o being set, LC_AlL being set, or the lack of a suitable target locale) ee also PEP 540- Add a new UTF-8 mode Pep written and implemented by victor Stinner 2.4 PEP 553: Built-in breakpoint( Python 3. 7 includes the ncw built-in breakpoint( function as an casy and consistcnt way to cntor the Python debugger Built-in breakpoint() calls sys. breakpointhook(. By default, the latter imports pdb and then calls pdb set_trace, but by binding sys. breakpointhook( to the function of your choosing, breakpoint() can enter any debugger. Additionally, the environment variable PYTHONBREAKPOINT can be set to the callable of your debugger of choice. Set PYTHONBREAKPOINT=o to completely disable built-in breakpoint() PEP 553- Built-in breakpoint( PEP written and implcmcntcd by Barry Warsaw 2.5 PEP 539: New C API for Thread-Local Storage While Python provides a C API for thread-local storage support; the existing Thread Local Storage(TLS) API has used int to represent TLS keys across all platforms. This has not generally been a problem for officially-support platforms, but that is neither POSiX-compliant, nor portable in any practical sense PEP 539 changes this by providing a new w Thread Specific Storage(TSS)API to CPython which supersede use of the existing TLS API within the CPython interpreter, while deprecating the existing API. The TSS API uses a new type Py_tss_t instead of int to represent Tss keys- an opaque type the definition of which may depend on the underlying TLS implementation. Therefore, this will allow to build CPython on platforms where the native tls key is defined in a way that cannot be safely cast to int Note that on platforms where the native tls key is defined in a way that cannot be safely cast to int, all functions of the existing TLS API will be no-op and immediately return failure. This indicates clearly that the old API is not supported on platforms where it cannot be used reliably, and that no effort will be made to add such support See also: PEP 539-A New C-API for Thread-Local Storage in CPython PEP written by Frik M. bray; implementation by masayuki Yamamoto 2.6 PEP 562: Customization of Access to module Attributes otherwise not found. Defining setattr on mo dules and will call it whenever a module attribute is Python 3. 7 allows defining dir on modules is now also allowed A typical example of where this may be useful is module attribute deprecation and lazy loading See also PEP 562- Module __getattr__ and __dir__ PEP written and implemented by Ivan Levkivskyi 2.7 PEP 564: New Time Functions with Nanosecond resolution The resolution of clocks in modern systems can exceed the limited precision of a floating point number returned by the time. time() function and its variants. To avoid loss of precision, PEP 564 adds six new nanosecond"variants of the existing timer functions to the time module 七ine. clock_gettime_n( ·七ime. clock settime ns( ·time. monotonic ns() ·t七ine.perf_ counter_ns( time process time nso) time. time nso 7 The new functions return the number of nanoseconds as an integer value Measurements show that on Linux and Windows the resolution of time. time_ns( is approximately 3 times better than that of time. time o See als PEP 564- Add new time functions with nanosecond resolution PEP written and implemented by Victor Stinger 2.8 PEP 565: Show Deprecation Warning in__main The default handling of DeprecationWarning has been changed such that these warnings are once Inore shown by default, but only when the code triggering them is running directly in the__main_- module. As a result, developers of single file scripts and those using Python interactively should once again start seeing deprecation warnings for the APIs they use, but deprecation warnings triggered by imported application ibrary and framework modules will continue to be hidden by default As a result of this change, the standard library now allows developers to choose between three different deprecation warning behaviours FutureWarning always displayed by default, recommended for warnings intended to be seen by ap plication cnd uscrs(cg. for dcprccatcd application configuration settings) DeprecationWarning: displayed by default only in__main__ and when running tests, recommended for warnings intended to be seen by other Python developers where a version upgrade may result in changcd bchaviour or an crror Pending DeprecationWarning: displayed by default only when running tests intended for cases where a future version upgrade will change the warning category to DeprecationWarning or FutureWarning Previously both DeprecationWarning and PendingDeprecationWarning were only visible when running tests, which meant that developers primarily writing single file scripts or using Python interactively could be surprised by breaking changes in the APls they used See also PEP 565- Show Deprecation warning main PEP written and implemented by Nick Coghlan 2.9 PEP 560: Core Support for typing module and Generic Types Initially PEP 484 was designed in such way that it would not introduce any changes to the core CPython interpreter. Now type hints and the typing module are extensively used by the community, so this restriction is removed. The PEP introduces two special methods_class_getitem__(and__mro_entries_-, these methods are now used by most classes and special constructs in typing. As a result, the speed of various opcrations with typos incrcascd up to 7 timos, the gencric types can be used without metaclass conflicts anld several long standing bugs in typing nodule are fixed See also PEP 560- Core support for typing module and generic types PEP written and implemented b Ivan Levkivskyi 2.10 PEP 552: Hash-based. pyc Files Python has traditionally checked the up-to-dateness of bytecode cache files (i.e.,. pyc files) by comparing the sourcc mctadata(last-modificd timestamp and sizc) with sourcc mctadata saved in the cache filc hcadcr when 8 it was generated. While effective, this invalidation method has its drawbacks. When filesystem timestamps are too coarse, Python can miss source updates, leading to user confusion. Additionally, having a timestamp in the cache file is problematic for build reproducibility and content-based build systems PEP 552 extends the pyc format to allow the hash of the source file to be used for invalidation instead of the source timestamp. Such. pyc files are called"hash-based". By defauIt, Python still uses timestamp-based invalidation and does not generate hash-based. pyc files at runtime. Hash-based. pyc files may be generated with py_ compile or compileall Hash-based. pyc files come in two variants: checked and unchecked. Python va. lidates checked hash-based pyc files against the corresponding source files at runtime but doesnt do so for unchecked hash-based pyes Unchecked hash-based. pyc files are a useful performance optimization for environments where a system external to Python(e.g, the build system) is responsible for keeping. pyc files up-to-date See pyc-invalidation for more information See also PEP 552- Deterministic pycs PEP written and implemented by Benjamin Peterson 2.11 PEP 545: Python Documentation Translations PEP 545 dcscribcs the proccss of crcating and maintaining Python documentation translations Three new translations have been added Japanese:https://docs.pythonorg/ja/ French:https://docs.python.org/fr/ Korean:https://docs.pythonorg/ko See also PEP 545- Python Documentation Translations PEP written and implemented by Julien Palard, In- ada Naoki and Victor Stinner 2.12 Development Runtime Mode:-x dev The new-X dev command line option or the new PYTHONDEVMODE environment variable can be used to enable CPython's development mode. When in development mode, CPython performs additional runtime checks that are too expensive to be enabled by default. See -X dev documentation for the full description of the cffccts of this modc 3 Other Language Changes More than 255 arguments can now be passed to a function, and a function can now have more than 255 parameters.( Contributed by Serhiy Storchaka in bpo-12844 and bpo-18896) bytes. fromhex()and bytearray. fromhexo now ignore all AsciI whitespace, not only spaces.( Con- tributed by robert Xiao in bpo-28927) str, bytes, and bytearray gained support for the new isascii() method, which can be used to test. if a string or bytes contain only the ASCll characters.(Contributed by INADA Naoki in bpo-32677 ImportError now displays Nodule llaine and Nodule__file_- path whien from .. import .. fails Contributed by Matthias Bulssonnier in bpo-29546 9 Circular imports involving absolute imports with binding a submodule to a name are now supported Contributed by Serhiy Storchaka in bpo-30024 object. _format__(x, I')is now cquivalent to str(x)rathcr than format(str(self),1).(Con tributed by Serhiy Storchaka in bpo-28974) In order to better support dynamic creation of stack traces, types. TracebackType can now be instan iatcd from Python codc, and the tb_next attribute on traccbacks is now writable.(Contributcd by Nathaniel J. Simith in bpo-30579. When using the -m switch, sys. path [o] is now eagerly expanded to the full starting directory path rather than being left as the empty directory(which allows imports from the current working directory at the tiine when all inport occurs)(Contributed by Nick Coghlan in bpo-33053) The new -X importtime option or the PYTHONPROFILEIMPORTTIME environment variable can be used to show the timing of each module import.(Contributed by Victor Stinner in bpo-31415) 4 New modules 4.1 contextvars The new contextvars module and a set of new C aPis introduce support for contect variables. Context vari- ables are conceptually similar to thread-local variables. Unlike TLs, context variables support asynchronous code correctly asyncio and decimal modules have been updated to use and support context variables out of the box Particularly the active decimal context is now stored in a context variable, which allows decimal operations to work with the correct context in asynchronous codc ee also PEP 567- Context Variables PEP written and implemented by Yury selivanov 4.2 dataclasses The new dataclass( decorator provides a way to declare data classes. a data class describes its attributes using class variable alllotatiOIs. Its constructor and other Inlagie Inethods, such as__repr__O) () and _hash__( are generated automatically Example @dataclass class point x: float y: float z;f10at=0.0 p= Point(1.5,2.5) print(p) produces "Point(a=1. 5,y=2.5, 2=0.0) See also PEP 557- Data Classes PEP written alld iinpleinented by Eric V. SInlith 10

...展开详情
所需积分/C币:5 上传时间:2019-05-21 资源大小:13.71MB
举报 举报 收藏 收藏
分享 分享
高效算法(python描述)

本书旨在探讨如何优化算法效率,详细阐述了经典算法和特殊算法的实现、应用技巧和复杂度验证过程,内容由浅入深,能帮助读者快速掌握复杂度适当、正确率高的高效编程方法以及自检、自测技巧,是参加ACM/ICPC、Google Code Jam 等国际编程竞赛、备战编程考试、提高编程效率、优化编程方法的参考书目。

立即下载
python关于小说的简易爬虫程序

关于小说的简易爬虫,仅供大家进行学习参考,有问题可以一块讨论

立即下载
python新浪微博爬虫,爬取微博和用户信息 (源码)

这是新浪微博爬虫,采用python+selenium实现。 免费资源,希望对你有所帮助,虽然是傻瓜式爬虫,但是至少能运行。同时rar中包括源码及爬取的示例。 参考我的文章: http://blog.csdn.net/eastmount/article/details/50720436 [python爬虫] Selenium爬取新浪微博内容及用户信息 http://blog.csdn.net/eastmount/article/details/51231852 [Python爬虫] Selenium爬取新浪微博客户端用户信息、热点话题及评论 (上) 主要爬取内容包括: 新浪微博手机端用户信息

立即下载
基于色度学的舌色分类研究现状与分析

基于色度学的舌色分类研究现状与分析,杨新宇,梁嵘,目的:探讨基于色度学的舌色分类研究现状,为数字舌图的舌色分类研究提供依据与参考。方法:回顾性分析22项舌色分类研究的数据,�

立即下载
基于选课的需求做出来的部分代码实现.zip

自己写的项目,基于选课的需求做出来的部分代码实现,可以学习参考。实现了学校的录入,老师的录入,班级的录入,课程的录入,包括之间的对应关系

立即下载
ModbusTCP/RTU网关设计

基于UIP协议栈,实现MODBUS联网,可参考本文档资料,有MODBUS协议介绍

立即下载
html+css+js制作的一个动态的新年贺卡

该代码是http://blog.csdn.net/qq_29656961/article/details/78155792博客里面的代码,代码里面有要用到的图片资源和音乐资源。

立即下载
iCopy解码软件v1.0.1.7.exe

解ic,id,hid卡密码破解ic,id,hid卡密码破解ic,id,hid破解ic,id,hid卡破解ic,id,hid卡密码密码卡密码破解ic,id,hid卡...

立即下载
分布式服务框架原理与实践(高清完整版)

第1章应用架构演进1 1.1传统垂直应用架构2 1.1.1垂直应用架构介绍2 1.1.2垂直应用架构面临的挑战4 1.2RPC架构6 1.2.1RPC框架原理6 1.2.2最简单的RPC框架实现8 1.2.3业界主流RPC框架14 1.2.4RPC框架面临的挑战17 1.3SOA服务化架构18 1.3.1面向服务设计的原则18 1.3.2服务治理19 1.4微服务架构21 1.4.1什么是微服务21 1.4.2微服务架构对比SOA22 1.5总结23 第2章分布式服务框架入门25 2.1分布式服务框架诞生背景26 2.1.1应用从集中式走向分布式.26?

立即下载
Camtasia 9安装及破解方法绝对有效

附件中注册方法亲测有效,加以整理与大家共享。 由于附件大于60m传不上去,另附Camtasia 9百度云下载地址。免费自取 链接:http://pan.baidu.com/s/1kVABnhH 密码:xees

立即下载
电磁场与电磁波第四版谢处方 PDF

电磁场与电磁波第四版谢处方 (清晰版),做天线设计的可以作为参考。

立即下载
压缩包爆破解密工具(7z、rar、zip)

压缩包内包含三个工具,分别可以用来爆破解密7z压缩包、rar压缩包和zip压缩包。

立即下载
source insight 4.0.0087 注册机序列号Patched(2017/10/17)

最新的sourceinsight4.0.0087和谐license及和谐文件。真正的4087版本,使用附件中的license文件,替换sourceinsight4.exe

立即下载
Java项目经验汇总(简历项目素材)

Java项目经验汇总(简历项目素材)

立即下载
支付宝转账demo

支付宝单笔转账,实现提现功能(内有demo实例,望大家多多提意见)

立即下载
算法第四版 高清完整中文版PDF

《算法 第4版 》是Sedgewick之巨著 与高德纳TAOCP一脉相承 是算法领域经典的参考书 涵盖所有程序员必须掌握的50种算法 全面介绍了关于算法和数据结构的必备知识 并特别针对排序 搜索 图处理和字符串处理进行了论述 第4版具体给出了每位程序员应知应会的50个算法 提供了实际代码 而且这些Java代码实现采用了模块化的编程风格 读者可以方便地加以改造

立即下载
计算机中丢失api-ms-win-crt-runtime-l1-1-0.dll的修复方案

计算机中丢失api-ms-win-crt-runtime-l1-1-0.dll的修复方案

立即下载
最新的微信小程序源码

最新的微信小程序源码70多个很多行业都有加后台

立即下载
数据库系统概念第六版答案(最全)

史上最全的数据库系统概念第六版(机械工业出版社)课本答案

立即下载
c语言程序设计pdf——谭浩强.pdf

C语言是一门通用计算机编程语言,应用广泛。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。

立即下载