Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
92ba2868
Kaydet (Commit)
92ba2868
authored
Eyl 06, 2010
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More updates to whatsnew3.2
üst
6db77305
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
46 deletions
+91
-46
3.2.rst
Doc/whatsnew/3.2.rst
+91
-46
No files found.
Doc/whatsnew/3.2.rst
Dosyayı görüntüle @
92ba2868
...
@@ -53,22 +53,18 @@ This article explains the new features in Python 3.2, compared to 3.1.
...
@@ -53,22 +53,18 @@ This article explains the new features in Python 3.2, compared to 3.1.
PEP 391: Dictionary Based Configuration for Logging
PEP 391: Dictionary Based Configuration for Logging
====================================================
====================================================
The :mod:`logging` module had two ways of configuring the module, either by calling
The :mod:`logging` module provided two kinds of configuration, one style with
functions for each option or by reading an external file saved in a :mod:`ConfigParser`
function calls for each option or another style driven by an external file saved
format. Those options did not provide the flexibility to create configurations
in a :mod:`ConfigParser` format. Those options did not provide the flexibility
from JSON or YAML files and they did not support incremental configuration, which
to create configurations from JSON or YAML files, nor they did not support
is needed for specifying logger options from a command line.
incremental configuration, which is needed for specifying logger options from a
command line.
To support a more flexible style, the module now offers
To support a more flexible style, the module now offers
:func:`logging.config.dictConfig` to use dictionaries to specify logger
:func:`logging.config.dictConfig` for specifying logging configuration with
configuration (including formatters, handlers, filters, and loggers). For
plain Python dictionaries. The configuration options include formatters,
example:
handlers, filters, and loggers. Here's a working example of a configuration
dictionary::
>>> import logging.config
>>> logging.config.dictConfig(json.load(open('log.cfg', 'rb')))
The above fragment configures logging from a JSON-encoded dictionary stored in a
file called "log.cfg". Here's a working example of a configuration dictionary::
{"version": 1,
{"version": 1,
"formatters": {"brief": {"format": "%(levelname)-8s: %(name)-15s: %(message)s"},
"formatters": {"brief": {"format": "%(levelname)-8s: %(name)-15s: %(message)s"},
...
@@ -87,6 +83,15 @@ file called "log.cfg". Here's a working example of a configuration dictionary::
...
@@ -87,6 +83,15 @@ file called "log.cfg". Here's a working example of a configuration dictionary::
},
},
"root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}}
"root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}}
If that dictionary is stored in a file called "conf.json", it can loaded
and called with code like this::
>>> import logging.config
>>> logging.config.dictConfig(json.load(open('conf.json', 'rb')))
>>> logging.info("Transaction completed normally")
>>> logging.critical("Abnormal termination")
.. seealso::
.. seealso::
:pep:`391` - Dictionary Based Configuration for Logging
:pep:`391` - Dictionary Based Configuration for Logging
...
@@ -119,16 +124,16 @@ aspects that are visible to the programmer:
...
@@ -119,16 +124,16 @@ aspects that are visible to the programmer:
* Imported modules now have a :attr:`__cached__` attribute which stores the name
* Imported modules now have a :attr:`__cached__` attribute which stores the name
of the actual file that was imported:
of the actual file that was imported:
>>> import collections
>>> import collections
>>> collections.__cached__
>>> collections.__cached__
'c:/py32/lib/__pycache__/collections.cpython-32.pyc'
'c:/py32/lib/__pycache__/collections.cpython-32.pyc'
* The tag that is unique to each interpreter is accessible from the :mod:`imp`
* The tag that is unique to each interpreter is accessible from the :mod:`imp`
module:
module:
>>> import imp
>>> import imp
>>> imp.get_tag()
>>> imp.get_tag()
'cpython-32'
'cpython-32'
* Scripts that try to deduce source filename from the imported file now need to
* Scripts that try to deduce source filename from the imported file now need to
be smarter. It is no longer sufficient to simply strip the "c" from a ".pyc"
be smarter. It is no longer sufficient to simply strip the "c" from a ".pyc"
...
@@ -199,10 +204,10 @@ Some smaller changes made to the core Python language are:
...
@@ -199,10 +204,10 @@ Some smaller changes made to the core Python language are:
caused confusion and is no longer needed now that the shortest possible
caused confusion and is no longer needed now that the shortest possible
:func:`repr` is displayed by default:
:func:`repr` is displayed by default:
>>> repr(math.pi)
>>> repr(math.pi)
'3.141592653589793'
'3.141592653589793'
>>> str(math.pi)
>>> str(math.pi)
'3.141592653589793'
'3.141592653589793'
(Proposed and implemented by Mark Dickinson; :issue:`9337`.)
(Proposed and implemented by Mark Dickinson; :issue:`9337`.)
...
@@ -218,8 +223,22 @@ Some smaller changes made to the core Python language are:
...
@@ -218,8 +223,22 @@ Some smaller changes made to the core Python language are:
* The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
* The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
:func:`~abc.abstractstaticmethod`.
:func:`~abc.abstractstaticmethod`.
(:issue:`5867`.)
(Patch submitted by Daniel Urban; :issue:`5867`.)
* A warning message will now get printed at interpreter shutdown if the
:data:`gc.garbage` list isn't empty. This is meant to make the programmer
aware that their code contains object finalization issues.
(Added by Antoine Pitrou; :issue:`477863`.)
* Mark Dickinson crafted an elegant and efficient scheme for assuring that
different numeric datatypes will have the same hash value whenever their
actual values are equal::
>>> assert hash(Fraction(3, 2)) == hash(1.5) == \
hash(Decimal("1.5")) == hash(complex(1.5, 0))
(See :issue:`8188`.)
New, Improved, and Deprecated Modules
New, Improved, and Deprecated Modules
=====================================
=====================================
...
@@ -263,26 +282,28 @@ New, Improved, and Deprecated Modules
...
@@ -263,26 +282,28 @@ New, Improved, and Deprecated Modules
* The :class:`ftplib.FTP` class now supports the context manager protocol to
* The :class:`ftplib.FTP` class now supports the context manager protocol to
unconditionally consume :exc:`socket.error` exceptions and to close the FTP
unconditionally consume :exc:`socket.error` exceptions and to close the FTP
connection when done:
connection when done:
:
>>> from ftplib import FTP
>>> from ftplib import FTP
>>> with FTP("ftp1.at.proftpd.org") as ftp:
>>> with FTP("ftp1.at.proftpd.org") as ftp:
... ftp.login()
... ftp.login()
... ftp.dir()
... ftp.dir()
...
...
'230 Anonymous login ok, restrictions apply.'
'230 Anonymous login ok, restrictions apply.'
dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 .
dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 .
dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 ..
dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 ..
dr-xr-xr-x 5 ftp ftp 4096 May 6 10:43 CentOS
dr-xr-xr-x 5 ftp ftp 4096 May 6 10:43 CentOS
dr-xr-xr-x 3 ftp ftp 18 Jul 10 2008 Fedora
dr-xr-xr-x 3 ftp ftp 18 Jul 10 2008 Fedora
(Contributed by Tarek Ziadé and Giampaolo Rodolà; :issue:`4972`.)
Other file-like objects such as :class:`mmap.mmap` and :func:`fileinput.input`
also grew auto-closing context managers::
* A warning message will now get printed at interpreter shutdown if the
with fileinput.input(files=('log1.txt', 'log2.txt')) as f:
:data:`gc.garbage` list isn't empty. This is meant to make the programmer
for line in f:
aware that their code contains object finalization issues.
process(line)
(Added by Antoine Pitrou; :issue:`477863`.)
(Contributed by Tarek Ziadé and Giampaolo Rodolà in :issue:`4972`, and
by Georg Brandl in :issue:`8046` and :issue:`1286`.)
* The :mod:`os` module now has the :const:`ST_RDONLY` and :const:`ST_NOSUID`
* The :mod:`os` module now has the :const:`ST_RDONLY` and :const:`ST_NOSUID`
constants, for use with the :func:`~os.statvfs` function.
constants, for use with the :func:`~os.statvfs` function.
...
@@ -395,15 +416,39 @@ Multi-threading
...
@@ -395,15 +416,39 @@ Multi-threading
argument. (Contributed by Torsten Landschoff; :issue:`850728`.)
argument. (Contributed by Torsten Landschoff; :issue:`850728`.)
..
Optimizations
Optimizations
=============
=============
Major
performance enhancements have been added:
A number of small
performance enhancements have been added:
* Stub
* JSON decoding performance is improved and memory consumption is reduced
whenever the same string is repeated for multiple keys.
(Contributed by Antoine Pitrou; :issue:`7451`.)
- Python's peephole optimizer now recognizes patterns such ``x in {1, 2, 3}`` as
being a test for membership in a set of constants. The optimizer recasts the
:class:`set` as a :class:`frozenset` and stores the pre-built constant.
Now that the speed penalty is gone, it is practical to start writing
membership tests using set-notation. This style is both semantically clear
and operationally fast::
extension = name.rpartition('.')[2]
if extension in {'xml', 'html', 'xhtml', 'css'}:
handle(name)
(Patch and additional tests by Dave Malcolm; :issue:`6690`).
* The fast-search algorithm in stringlib is now used by the :meth:`split`,
:meth:`rsplit`, :meth:`splitlines` and :meth:`replace` methods on
:class:`bytes`, :class:`bytearray` and :class:`str` objects. Likewise, the
algorithm is also used by :meth:`rfind`, :meth:`rindex`, :meth:`rsplit` and
:meth:`rpartition`.
(Patch by Florent Xicluna in :issue:`7622` and :issue:`7462`.)
Filenames and
u
nicode
Filenames and
U
nicode
=====================
=====================
The filesystem encoding can be specified by setting the
The filesystem encoding can be specified by setting the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment