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
20566845
Kaydet (Commit)
20566845
authored
Ock 12, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
properly implement cmp() for class instances
üst
a597dde3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
object.c
Objects/object.c
+31
-0
No files found.
Objects/object.c
Dosyayı görüntüle @
20566845
...
...
@@ -201,6 +201,19 @@ strobject(v)
}
}
static
object
*
do_cmp
(
v
,
w
)
object
*
v
,
*
w
;
{
/* __rcmp__ actually won't be called unless __cmp__ isn't defined,
because the check in cmpobject() reverses the objects first.
This is intentional -- it makes no sense to define cmp(x,y) different
than -cmp(y,x). */
if
(
is_instanceobject
(
v
)
||
is_instanceobject
(
w
))
return
instancebinop
(
v
,
w
,
"__cmp__"
,
"__rcmp__"
,
do_cmp
);
return
newintobject
((
long
)
cmpobject
(
v
,
w
));
}
int
cmpobject
(
v
,
w
)
object
*
v
,
*
w
;
...
...
@@ -212,6 +225,24 @@ cmpobject(v, w)
return
-
1
;
if
(
w
==
NULL
)
return
1
;
if
(
is_instanceobject
(
v
)
||
is_instanceobject
(
w
))
{
object
*
res
;
int
c
;
if
(
!
is_instanceobject
(
v
))
return
-
cmpobject
(
w
,
v
);
res
=
do_cmp
(
v
,
w
);
if
(
res
==
NULL
)
{
err_clear
();
return
(
v
<
w
)
?
-
1
:
1
;
}
if
(
!
is_intobject
(
res
))
{
DECREF
(
res
);
return
(
v
<
w
)
?
-
1
:
1
;
}
c
=
getintvalue
(
res
);
DECREF
(
res
);
return
(
c
<
0
)
?
-
1
:
(
c
>
0
)
?
1
:
0
;
}
if
((
tp
=
v
->
ob_type
)
!=
w
->
ob_type
)
{
if
(
tp
->
tp_as_number
!=
NULL
&&
w
->
ob_type
->
tp_as_number
!=
NULL
)
{
...
...
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