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
a3b11e7f
Kaydet (Commit)
a3b11e7f
authored
Ara 31, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
* Simplify and speedup logic for tp_print.
* Speed-up intersection whenever PyDict_Next can be used.
üst
a1805815
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
15 deletions
+29
-15
setobject.c
Objects/setobject.c
+29
-15
No files found.
Objects/setobject.c
Dosyayı görüntüle @
a3b11e7f
...
...
@@ -240,7 +240,7 @@ static PyObject *
set_intersection
(
PySetObject
*
so
,
PyObject
*
other
)
{
PySetObject
*
result
;
PyObject
*
item
,
*
selfdata
,
*
tgtdata
,
*
it
;
PyObject
*
item
,
*
selfdata
,
*
tgtdata
,
*
it
,
*
tmp
;
result
=
(
PySetObject
*
)
make_new_set
(
so
->
ob_type
,
NULL
);
if
(
result
==
NULL
)
...
...
@@ -248,14 +248,27 @@ set_intersection(PySetObject *so, PyObject *other)
tgtdata
=
result
->
data
;
selfdata
=
so
->
data
;
if
(
PyAnySet_Check
(
other
)
&&
PyDict_Size
(((
PySetObject
*
)
other
)
->
data
)
>
PyDict_Size
(
selfdata
))
{
selfdata
=
((
PySetObject
*
)
other
)
->
data
;
other
=
(
PyObject
*
)
so
;
}
else
if
(
PyDict_Check
(
other
)
&&
PyDict_Size
(
other
)
>
PyDict_Size
(
selfdata
))
{
if
(
PyAnySet_Check
(
other
))
other
=
((
PySetObject
*
)
other
)
->
data
;
if
(
PyDict_Check
(
other
)
&&
PyDict_Size
(
other
)
>
PyDict_Size
(
selfdata
))
{
tmp
=
selfdata
;
selfdata
=
other
;
other
=
so
->
data
;
other
=
tmp
;
}
if
(
PyDict_CheckExact
(
other
))
{
PyObject
*
value
;
int
pos
=
0
;
while
(
PyDict_Next
(
other
,
&
pos
,
&
item
,
&
value
))
{
if
(
PyDict_Contains
(
selfdata
,
item
))
{
if
(
PyDict_SetItem
(
tgtdata
,
item
,
Py_True
)
==
-
1
)
{
Py_DECREF
(
result
);
return
NULL
;
}
}
}
return
(
PyObject
*
)
result
;
}
it
=
PyObject_GetIter
(
other
);
...
...
@@ -719,18 +732,18 @@ static int
set_tp_print
(
PySetObject
*
so
,
FILE
*
fp
,
int
flags
)
{
PyObject
*
key
,
*
value
;
int
pos
=
0
,
firstpass
=
1
;
int
pos
=
0
;
char
*
emit
=
""
;
/* No separator emitted on first pass */
char
*
separator
=
", "
;
fprintf
(
fp
,
"%s(["
,
so
->
ob_type
->
tp_name
);
while
(
PyDict_Next
(
so
->
data
,
&
pos
,
&
key
,
&
value
))
{
if
(
firstpass
)
firstpass
=
0
;
else
fprintf
(
fp
,
", "
);
fputs
(
emit
,
fp
);
emit
=
separator
;
if
(
PyObject_Print
(
key
,
fp
,
0
)
!=
0
)
return
-
1
;
}
fp
rintf
(
fp
,
"])"
);
fp
uts
(
"])"
,
fp
);
return
0
;
}
...
...
@@ -1077,7 +1090,8 @@ PyTypeObject PyFrozenSet_Type = {
0
,
/* ob_size */
"frozenset"
,
/* tp_name */
sizeof
(
PySetObject
),
/* tp_basicsize */
0
,
/* tp_itemsize */
/* methods */
0
,
/* tp_itemsize */
/* methods */
(
destructor
)
set_dealloc
,
/* tp_dealloc */
(
printfunc
)
set_tp_print
,
/* tp_print */
0
,
/* tp_getattr */
...
...
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