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
a3a53180
Kaydet (Commit)
a3a53180
authored
Şub 02, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF patch #678899: Save time and memory by using itertools in sets module.
üst
efb9625b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
19 deletions
+11
-19
sets.py
Lib/sets.py
+11
-19
No files found.
Lib/sets.py
Dosyayı görüntüle @
a3a53180
...
@@ -57,7 +57,7 @@ what's tested is actually `z in y'.
...
@@ -57,7 +57,7 @@ what's tested is actually `z in y'.
__all__
=
[
'BaseSet'
,
'Set'
,
'ImmutableSet'
]
__all__
=
[
'BaseSet'
,
'Set'
,
'ImmutableSet'
]
from
itertools
import
ifilter
class
BaseSet
(
object
):
class
BaseSet
(
object
):
"""Common base class for mutable and immutable sets."""
"""Common base class for mutable and immutable sets."""
...
@@ -182,7 +182,7 @@ class BaseSet(object):
...
@@ -182,7 +182,7 @@ class BaseSet(object):
little
,
big
=
self
,
other
little
,
big
=
self
,
other
else
:
else
:
little
,
big
=
other
,
self
little
,
big
=
other
,
self
common
=
filter
(
big
.
_data
.
has_key
,
little
.
_data
)
common
=
ifilter
(
big
.
_data
.
has_key
,
little
)
return
self
.
__class__
(
common
)
return
self
.
__class__
(
common
)
def
intersection
(
self
,
other
):
def
intersection
(
self
,
other
):
...
@@ -204,12 +204,10 @@ class BaseSet(object):
...
@@ -204,12 +204,10 @@ class BaseSet(object):
value
=
True
value
=
True
selfdata
=
self
.
_data
selfdata
=
self
.
_data
otherdata
=
other
.
_data
otherdata
=
other
.
_data
for
elt
in
selfdata
:
for
elt
in
ifilter
(
otherdata
.
has_key
,
selfdata
,
True
):
if
elt
not
in
otherdata
:
data
[
elt
]
=
value
data
[
elt
]
=
value
for
elt
in
ifilter
(
selfdata
.
has_key
,
otherdata
,
True
):
for
elt
in
otherdata
:
data
[
elt
]
=
value
if
elt
not
in
selfdata
:
data
[
elt
]
=
value
return
result
return
result
def
symmetric_difference
(
self
,
other
):
def
symmetric_difference
(
self
,
other
):
...
@@ -228,11 +226,9 @@ class BaseSet(object):
...
@@ -228,11 +226,9 @@ class BaseSet(object):
return
NotImplemented
return
NotImplemented
result
=
self
.
__class__
()
result
=
self
.
__class__
()
data
=
result
.
_data
data
=
result
.
_data
otherdata
=
other
.
_data
value
=
True
value
=
True
for
elt
in
self
:
for
elt
in
ifilter
(
other
.
_data
.
has_key
,
self
,
True
):
if
elt
not
in
otherdata
:
data
[
elt
]
=
value
data
[
elt
]
=
value
return
result
return
result
def
difference
(
self
,
other
):
def
difference
(
self
,
other
):
...
@@ -264,10 +260,8 @@ class BaseSet(object):
...
@@ -264,10 +260,8 @@ class BaseSet(object):
self
.
_binary_sanity_check
(
other
)
self
.
_binary_sanity_check
(
other
)
if
len
(
self
)
>
len
(
other
):
# Fast check for obvious cases
if
len
(
self
)
>
len
(
other
):
# Fast check for obvious cases
return
False
return
False
otherdata
=
other
.
_data
for
elt
in
ifilter
(
other
.
_data
.
has_key
,
self
,
True
):
for
elt
in
self
:
return
False
if
elt
not
in
otherdata
:
return
False
return
True
return
True
def
issuperset
(
self
,
other
):
def
issuperset
(
self
,
other
):
...
@@ -275,9 +269,7 @@ class BaseSet(object):
...
@@ -275,9 +269,7 @@ class BaseSet(object):
self
.
_binary_sanity_check
(
other
)
self
.
_binary_sanity_check
(
other
)
if
len
(
self
)
<
len
(
other
):
# Fast check for obvious cases
if
len
(
self
)
<
len
(
other
):
# Fast check for obvious cases
return
False
return
False
selfdata
=
self
.
_data
for
elt
in
ifilter
(
self
.
_data
.
has_key
,
other
,
True
):
for
elt
in
other
:
if
elt
not
in
selfdata
:
return
False
return
False
return
True
return
True
...
...
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