Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a746b506
Commit
a746b506
authored
Jan 17, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use rich comparisons in min and max.
parent
f233879f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Python/bltinmodule.c
Python/bltinmodule.c
+9
-9
No files found.
Python/bltinmodule.c
View file @
a746b506
...
@@ -1371,7 +1371,7 @@ Return the dictionary containing the current scope's local variables.";
...
@@ -1371,7 +1371,7 @@ Return the dictionary containing the current scope's local variables.";
static
PyObject
*
static
PyObject
*
min_max
(
PyObject
*
args
,
int
sign
)
min_max
(
PyObject
*
args
,
int
op
)
{
{
int
i
;
int
i
;
PyObject
*
v
,
*
w
,
*
x
;
PyObject
*
v
,
*
w
,
*
x
;
...
@@ -1401,16 +1401,16 @@ min_max(PyObject *args, int sign)
...
@@ -1401,16 +1401,16 @@ min_max(PyObject *args, int sign)
if
(
w
==
NULL
)
if
(
w
==
NULL
)
w
=
x
;
w
=
x
;
else
{
else
{
int
c
=
PyObject_Compare
(
x
,
w
);
int
cmp
=
PyObject_RichCompareBool
(
x
,
w
,
op
);
if
(
c
&&
PyErr_Occurred
())
{
if
(
cmp
>
0
)
{
Py_DECREF
(
w
);
w
=
x
;
}
else
if
(
cmp
<
0
)
{
Py_DECREF
(
x
);
Py_DECREF
(
x
);
Py_XDECREF
(
w
);
Py_XDECREF
(
w
);
return
NULL
;
return
NULL
;
}
}
if
(
c
*
sign
>
0
)
{
Py_DECREF
(
w
);
w
=
x
;
}
else
else
Py_DECREF
(
x
);
Py_DECREF
(
x
);
}
}
...
@@ -1424,7 +1424,7 @@ min_max(PyObject *args, int sign)
...
@@ -1424,7 +1424,7 @@ min_max(PyObject *args, int sign)
static
PyObject
*
static
PyObject
*
builtin_min
(
PyObject
*
self
,
PyObject
*
v
)
builtin_min
(
PyObject
*
self
,
PyObject
*
v
)
{
{
return
min_max
(
v
,
-
1
);
return
min_max
(
v
,
Py_LT
);
}
}
static
char
min_doc
[]
=
static
char
min_doc
[]
=
...
@@ -1438,7 +1438,7 @@ With two or more arguments, return the smallest argument.";
...
@@ -1438,7 +1438,7 @@ With two or more arguments, return the smallest argument.";
static
PyObject
*
static
PyObject
*
builtin_max
(
PyObject
*
self
,
PyObject
*
v
)
builtin_max
(
PyObject
*
self
,
PyObject
*
v
)
{
{
return
min_max
(
v
,
1
);
return
min_max
(
v
,
Py_GT
);
}
}
static
char
max_doc
[]
=
static
char
max_doc
[]
=
...
...
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