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
9543b340
Kaydet (Commit)
9543b340
authored
Ock 18, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF patch #670423: Add missing identity tests to operator.c
üst
18acea7c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
3 deletions
+49
-3
liboperator.tex
Doc/lib/liboperator.tex
+9
-1
test_operator.py
Lib/test/test_operator.py
+11
-0
NEWS
Misc/NEWS
+5
-2
operator.c
Modules/operator.c
+24
-0
No files found.
Doc/lib/liboperator.tex
Dosyayı görüntüle @
9543b340
...
...
@@ -48,7 +48,7 @@ for more informations about rich comparisons.
The logical operations are also generally applicable to all objects,
and support truth tests and Boolean operations:
and support truth tests
, identity tests,
and Boolean operations:
\begin{funcdesc}
{
not
_}{
o
}
\funcline
{__
not
__}{
o
}
...
...
@@ -64,6 +64,14 @@ otherwise. This is equivalent to using the \class{bool}
constructor.
\end{funcdesc}
\begin{funcdesc}
{
is
_}{
a, b
}
Return
\code
{
\var
{
a
}
is
\var
{
b
}}
. Tests object identity.
\end{funcdesc}
\begin{funcdesc}
{
is
_
not
}{
a, b
}
Return
\code
{
\var
{
a
}
is not
\var
{
b
}}
. Tests object identity.
\end{funcdesc}
The mathematical and bitwise operations are the most numerous:
...
...
Lib/test/test_operator.py
Dosyayı görüntüle @
9543b340
...
...
@@ -215,6 +215,17 @@ class OperatorTestCase(unittest.TestCase):
def
test_bitwise_xor
(
self
):
self
.
failUnless
(
operator
.
xor
(
0xb
,
0xc
)
==
0x7
)
def
test_is
(
self
):
a
=
b
=
'xyzpdq'
c
=
a
[:
3
]
+
b
[
3
:]
self
.
failUnless
(
operator
.
is_
(
a
,
b
))
self
.
failIf
(
operator
.
is_
(
a
,
c
))
def
test_is_not
(
self
):
a
=
b
=
'xyzpdq'
c
=
a
[:
3
]
+
b
[
3
:]
self
.
failIf
(
operator
.
is_not
(
a
,
b
))
self
.
failUnless
(
operator
.
is_not
(
a
,
c
))
def
test_main
():
test_support
.
run_unittest
(
OperatorTestCase
)
...
...
Misc/NEWS
Dosyayı görüntüle @
9543b340
...
...
@@ -517,6 +517,11 @@ Core and builtins
Extension
modules
-----------------
-
Added
three
operators
to
the
operator
module
:
operator
.
pow
(
a
,
b
)
which
is
equivalent
to
:
a
**
b
.
operator
.
is_
(
a
,
b
)
which
is
equivalent
to
:
a
is
b
.
operator
.
is_not
(
a
,
b
)
which
is
equivalent
to
:
a
is
not
b
.
-
posix
.
openpty
now
works
on
all
systems
that
have
/
dev
/
ptmx
.
-
A
module
zipimport
exists
to
support
importing
code
from
zip
...
...
@@ -733,8 +738,6 @@ Library
or when you need to use sets as dict keys, and a class BaseSet which
is the base class of the two.
- Added operator.pow(a,b) which is equivalent to a**b.
- Added random.sample(population,k) for random sampling without replacement.
Returns a k length list of unique elements chosen from the population.
...
...
Modules/operator.c
Dosyayı görüntüle @
9543b340
...
...
@@ -107,6 +107,28 @@ op_pow(PyObject *s, PyObject *a)
return
NULL
;
}
static
PyObject
*
is_
(
PyObject
*
s
,
PyObject
*
a
)
{
PyObject
*
a1
,
*
a2
,
*
result
=
NULL
;
if
(
PyArg_UnpackTuple
(
a
,
"is_"
,
2
,
2
,
&
a1
,
&
a2
))
{
result
=
(
a1
==
a2
)
?
Py_True
:
Py_False
;
Py_INCREF
(
result
);
}
return
result
;
}
static
PyObject
*
is_not
(
PyObject
*
s
,
PyObject
*
a
)
{
PyObject
*
a1
,
*
a2
,
*
result
=
NULL
;
if
(
PyArg_UnpackTuple
(
a
,
"is_not"
,
2
,
2
,
&
a1
,
&
a2
))
{
result
=
(
a1
!=
a2
)
?
Py_True
:
Py_False
;
Py_INCREF
(
result
);
}
return
result
;
}
static
PyObject
*
op_getslice
(
PyObject
*
s
,
PyObject
*
a
)
{
...
...
@@ -182,6 +204,8 @@ spam1(countOf,
spam1o
(
isMappingType
,
"isMappingType(a) -- Return True if a has a mapping type, False otherwise."
)
spam1
(
is_
,
"is_(a, b) -- Same as a is b."
)
spam1
(
is_not
,
"is_not(a, b) -- Same as a is not b."
)
spam2
(
add
,
__add__
,
"add(a, b) -- Same as a + b."
)
spam2
(
sub
,
__sub__
,
"sub(a, b) -- Same as a - b."
)
spam2
(
mul
,
__mul__
,
"mul(a, b) -- Same as a * b."
)
...
...
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