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
65548873
Kaydet (Commit)
65548873
authored
Şub 02, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #11089: Fix performance issue limiting the use of ConfigParser()
with large config files.
üst
9f1ab853
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
configparser.py
Lib/configparser.py
+38
-4
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/configparser.py
Dosyayı görüntüle @
65548873
...
...
@@ -88,7 +88,7 @@ ConfigParser -- responsible for parsing a list of
"""
try
:
from
collections
import
OrderedDict
as
_default_dict
from
collections
import
Mapping
,
OrderedDict
as
_default_dict
except
ImportError
:
# fallback for setup.py which hasn't yet built _collections
_default_dict
=
dict
...
...
@@ -515,6 +515,38 @@ class RawConfigParser:
if
e
:
raise
e
class
_Chainmap
(
Mapping
):
"""Combine multiple mappings for successive lookups.
For example, to emulate Python's normal lookup sequence:
import __builtin__
pylookup = _Chainmap(locals(), globals(), vars(__builtin__))
"""
def
__init__
(
self
,
*
maps
):
self
.
maps
=
maps
def
__getitem__
(
self
,
key
):
for
mapping
in
self
.
maps
:
try
:
return
mapping
[
key
]
except
KeyError
:
pass
raise
KeyError
(
key
)
def
__iter__
(
self
):
seen
=
set
()
for
mapping
in
self
.
maps
:
s
=
set
(
mapping
)
-
seen
for
elem
in
s
:
yield
elem
seen
.
update
(
s
)
def
__len__
(
self
):
s
=
set
()
s
.
update
(
*
self
.
maps
)
return
len
(
s
)
class
ConfigParser
(
RawConfigParser
):
...
...
@@ -530,16 +562,18 @@ class ConfigParser(RawConfigParser):
The section DEFAULT is special.
"""
d
=
self
.
_defaults
.
copy
()
sectiondict
=
{}
try
:
d
.
update
(
self
.
_sections
[
section
])
sectiondict
=
self
.
_sections
[
section
]
except
KeyError
:
if
section
!=
DEFAULTSECT
:
raise
NoSectionError
(
section
)
# Update with the entry specific variables
vardict
=
{}
if
vars
:
for
key
,
value
in
vars
.
items
():
d
[
self
.
optionxform
(
key
)]
=
value
vardict
[
self
.
optionxform
(
key
)]
=
value
d
=
_Chainmap
(
vardict
,
sectiondict
,
self
.
_defaults
)
option
=
self
.
optionxform
(
option
)
try
:
value
=
d
[
option
]
...
...
Misc/NEWS
Dosyayı görüntüle @
65548873
...
...
@@ -37,6 +37,9 @@ Core and Builtins
Library
-------
- Issue #11089: Fix performance issue limiting the use of ConfigParser()
with large config files.
- Issue #8275: Fix passing of callback arguments with ctypes under Win64.
Patch by Stan Mihai.
...
...
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