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
cc9a951f
Kaydet (Commit)
cc9a951f
authored
Eki 05, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF #1313496: bisect C replacement doesn't accept named args
üst
892a33f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
22 deletions
+36
-22
test_bisect.py
Lib/test/test_bisect.py
+10
-0
_bisectmodule.c
Modules/_bisectmodule.c
+26
-22
No files found.
Lib/test/test_bisect.py
Dosyayı görüntüle @
cc9a951f
...
...
@@ -130,6 +130,16 @@ class TestBisect(unittest.TestCase):
def
test_backcompatibility
(
self
):
self
.
assertEqual
(
bisect
,
bisect_right
)
def
test_keyword_args
(
self
):
data
=
[
10
,
20
,
30
,
40
,
50
]
self
.
assertEqual
(
bisect_left
(
a
=
data
,
x
=
25
,
lo
=
1
,
hi
=
3
),
2
)
self
.
assertEqual
(
bisect_right
(
a
=
data
,
x
=
25
,
lo
=
1
,
hi
=
3
),
2
)
self
.
assertEqual
(
bisect
(
a
=
data
,
x
=
25
,
lo
=
1
,
hi
=
3
),
2
)
insort_left
(
a
=
data
,
x
=
25
,
lo
=
1
,
hi
=
3
)
insort_right
(
a
=
data
,
x
=
25
,
lo
=
1
,
hi
=
3
)
insort
(
a
=
data
,
x
=
25
,
lo
=
1
,
hi
=
3
)
self
.
assertEqual
(
data
,
[
10
,
20
,
25
,
25
,
25
,
30
,
40
,
50
])
#==============================================================================
class
TestInsort
(
unittest
.
TestCase
):
...
...
Modules/_bisectmodule.c
Dosyayı görüntüle @
cc9a951f
...
...
@@ -34,15 +34,16 @@ internal_bisect_right(PyObject *list, PyObject *item, int lo, int hi)
}
static
PyObject
*
bisect_right
(
PyObject
*
self
,
PyObject
*
args
)
bisect_right
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
PyObject
*
list
,
*
item
;
int
lo
=
0
;
int
hi
=
-
1
;
int
index
;
static
char
*
keywords
[]
=
{
"a"
,
"x"
,
"lo"
,
"hi"
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"OO|ii:bisect_right"
,
&
list
,
&
item
,
&
lo
,
&
hi
))
if
(
!
PyArg_ParseTuple
AndKeywords
(
args
,
kw
,
"OO|ii:bisect_right"
,
keywords
,
&
list
,
&
item
,
&
lo
,
&
hi
))
return
NULL
;
index
=
internal_bisect_right
(
list
,
item
,
lo
,
hi
);
if
(
index
<
0
)
...
...
@@ -51,7 +52,7 @@ bisect_right(PyObject *self, PyObject *args)
}
PyDoc_STRVAR
(
bisect_right_doc
,
"bisect_right(
list, item
[, lo[, hi]]) -> index
\n
\
"bisect_right(
a, x
[, lo[, hi]]) -> index
\n
\
\n
\
Return the index where to insert item x in list a, assuming a is sorted.
\n
\
\n
\
...
...
@@ -63,15 +64,16 @@ Optional args lo (default 0) and hi (default len(a)) bound the\n\
slice of a to be searched.
\n
"
);
static
PyObject
*
insort_right
(
PyObject
*
self
,
PyObject
*
args
)
insort_right
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
PyObject
*
list
,
*
item
,
*
result
;
int
lo
=
0
;
int
hi
=
-
1
;
int
index
;
static
char
*
keywords
[]
=
{
"a"
,
"x"
,
"lo"
,
"hi"
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"OO|ii:insort_right"
,
&
list
,
&
item
,
&
lo
,
&
hi
))
if
(
!
PyArg_ParseTuple
AndKeywords
(
args
,
kw
,
"OO|ii:insort_right"
,
keywords
,
&
list
,
&
item
,
&
lo
,
&
hi
))
return
NULL
;
index
=
internal_bisect_right
(
list
,
item
,
lo
,
hi
);
if
(
index
<
0
)
...
...
@@ -91,7 +93,7 @@ insort_right(PyObject *self, PyObject *args)
}
PyDoc_STRVAR
(
insort_right_doc
,
"insort_right(
list, item
[, lo[, hi]])
\n
\
"insort_right(
a, x
[, lo[, hi]])
\n
\
\n
\
Insert item x in list a, and keep it sorted assuming a is sorted.
\n
\
\n
\
...
...
@@ -129,15 +131,16 @@ internal_bisect_left(PyObject *list, PyObject *item, int lo, int hi)
}
static
PyObject
*
bisect_left
(
PyObject
*
self
,
PyObject
*
args
)
bisect_left
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
PyObject
*
list
,
*
item
;
int
lo
=
0
;
int
hi
=
-
1
;
int
index
;
static
char
*
keywords
[]
=
{
"a"
,
"x"
,
"lo"
,
"hi"
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"OO|ii:bisect_left"
,
&
list
,
&
item
,
&
lo
,
&
hi
))
if
(
!
PyArg_ParseTuple
AndKeywords
(
args
,
kw
,
"OO|ii:bisect_left"
,
keywords
,
&
list
,
&
item
,
&
lo
,
&
hi
))
return
NULL
;
index
=
internal_bisect_left
(
list
,
item
,
lo
,
hi
);
if
(
index
<
0
)
...
...
@@ -146,7 +149,7 @@ bisect_left(PyObject *self, PyObject *args)
}
PyDoc_STRVAR
(
bisect_left_doc
,
"bisect_left(
list, item
[, lo[, hi]]) -> index
\n
\
"bisect_left(
a, x
[, lo[, hi]]) -> index
\n
\
\n
\
Return the index where to insert item x in list a, assuming a is sorted.
\n
\
\n
\
...
...
@@ -158,15 +161,16 @@ Optional args lo (default 0) and hi (default len(a)) bound the\n\
slice of a to be searched.
\n
"
);
static
PyObject
*
insort_left
(
PyObject
*
self
,
PyObject
*
args
)
insort_left
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
PyObject
*
list
,
*
item
,
*
result
;
int
lo
=
0
;
int
hi
=
-
1
;
int
index
;
static
char
*
keywords
[]
=
{
"a"
,
"x"
,
"lo"
,
"hi"
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"OO|ii:insort_left"
,
&
list
,
&
item
,
&
lo
,
&
hi
))
if
(
!
PyArg_ParseTuple
AndKeywords
(
args
,
kw
,
"OO|ii:insort_left"
,
keywords
,
&
list
,
&
item
,
&
lo
,
&
hi
))
return
NULL
;
index
=
internal_bisect_left
(
list
,
item
,
lo
,
hi
);
if
(
index
<
0
)
...
...
@@ -186,7 +190,7 @@ insort_left(PyObject *self, PyObject *args)
}
PyDoc_STRVAR
(
insort_left_doc
,
"insort_left(
list, item
[, lo[, hi]])
\n
\
"insort_left(
a, x
[, lo[, hi]])
\n
\
\n
\
Insert item x in list a, and keep it sorted assuming a is sorted.
\n
\
\n
\
...
...
@@ -200,17 +204,17 @@ PyDoc_STRVAR(insort_doc, "Alias for insort_right().\n");
static
PyMethodDef
bisect_methods
[]
=
{
{
"bisect_right"
,
(
PyCFunction
)
bisect_right
,
METH_VARARGS
,
bisect_right_doc
},
METH_VARARGS
|
METH_KEYWORDS
,
bisect_right_doc
},
{
"bisect"
,
(
PyCFunction
)
bisect_right
,
METH_VARARGS
,
bisect_doc
},
METH_VARARGS
|
METH_KEYWORDS
,
bisect_doc
},
{
"insort_right"
,
(
PyCFunction
)
insort_right
,
METH_VARARGS
,
insort_right_doc
},
METH_VARARGS
|
METH_KEYWORDS
,
insort_right_doc
},
{
"insort"
,
(
PyCFunction
)
insort_right
,
METH_VARARGS
,
insort_doc
},
METH_VARARGS
|
METH_KEYWORDS
,
insort_doc
},
{
"bisect_left"
,
(
PyCFunction
)
bisect_left
,
METH_VARARGS
,
bisect_left_doc
},
METH_VARARGS
|
METH_KEYWORDS
,
bisect_left_doc
},
{
"insort_left"
,
(
PyCFunction
)
insort_left
,
METH_VARARGS
,
insort_left_doc
},
METH_VARARGS
|
METH_KEYWORDS
,
insort_left_doc
},
{
NULL
,
NULL
}
/* sentinel */
};
...
...
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