Trac 16127: reimplement comparison of PARI objects
Make <= and >= return True for equal PARI objects
Change doctest
Trac 16127: raise an error for inequalities with incomparable types
Trac #17026: use cmp_universal() instead of gcmp_string()
Improve sorting in splitting_field
Trac 16127: remove doctest
Trac #16127: Fix comparison of PARI objects

Comparison of PARI rationals is seriously broken:
{{{
sage: pari(1/2) < pari(1/3)
True
sage: pari(1) < pari(1/2)
True
}}}
Furthermore,the following PARI series and ''p''-adics are incorrectly
considered to be non-zero by `==` and `!=`:
{{{
sage: a = pari('O(x)'); a, a.type()
(O(x), 't_SER')
sage: b = pari('O(2)'); b, b.type()
(O(2), 't_PADIC')
sage: a.gequal(0)
True
sage: b.gequal(0)
True
sage: a == 0
False  # should be True
sage: b == 0
False  # should be True
}}}
These bugs are caused by `__cmp__()` calling the function `gcmp_sage()`
in `sage/libs/pari/misc.h` (custom replacement for PARI's `gcmp()`),
which uses string comparison for all types other than `t_INT` and
`t_REAL`.

A possible solution is to implement `gen._richcmp_c_impl()` and to fix
`gen._cmp_c_impl()` to use the standard PARI `gcmp()` instead of
`gcmp_sage()`.  This requires catching PARI "forbidden comparison"
errors.  There is actually a non-negligible speed-up if no such error
occurs, but a substantial penalty if an error does occur.

URL: http://trac.sagemath.org/16127
Reported by: pbruin
Ticket author(s): Peter Bruin
Reviewer(s): Jeroen Demeyer
Trac #17026: Compare PARI objects using cmp_universal() instead of strcmp()

After the separate implementations of `__cmp__()` and `__richcmp__()`
for PARI objects in #16127, it is a small step to replace the string
comparison in `__cmp__()` by the built-in PARI function
`cmp_universal()`.  This is faster, mathematically no more or less
meaningful, and (unlike string comparison) gives a total ordering on the
set of PARI objects up to the "indistinguishability" relation
(`gidentical()`).

An example of two elements that used to be indistinguishable to `cmp()`:
{{{
sage: a = pari("0*ffgen(ffinit(29, 10, 't))"); a
0
sage: b = pari(0); b
0
sage: cmp(a, b)
1
}}}

URL: http://trac.sagemath.org/17026
Reported by: pbruin
Ticket author(s): Peter Bruin
Reviewer(s): Jeroen Demeyer