MCPcopy Create free account
hub / github.com/numpy/numpy / PyObject_Cmp

Function PyObject_Cmp

numpy/core/include/numpy/npy_3kcompat.h:506–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504 */
505#if defined(NPY_PY3K)
506static inline int
507PyObject_Cmp(PyObject *i1, PyObject *i2, int *cmp)
508{
509 int v;
510 v = PyObject_RichCompareBool(i1, i2, Py_LT);
511 if (v == 1) {
512 *cmp = -1;
513 return 1;
514 }
515 else if (v == -1) {
516 return -1;
517 }
518
519 v = PyObject_RichCompareBool(i1, i2, Py_GT);
520 if (v == 1) {
521 *cmp = 1;
522 return 1;
523 }
524 else if (v == -1) {
525 return -1;
526 }
527
528 v = PyObject_RichCompareBool(i1, i2, Py_EQ);
529 if (v == 1) {
530 *cmp = 0;
531 return 1;
532 }
533 else {
534 *cmp = 0;
535 return -1;
536 }
537}
538#endif
539
540/*

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected