In that case I would rather see the `<=>` operator; having to call `compare_function()` twice for 66% of the times doesn't sound like an attractive solution. A simple `switch (Z_TYPE_P(retval))` would do the job well here.