Use `PyList_CheckExact` and `PyTuple_CheckExact` (which are just macros that expand into these pointer comparisons, but it's better to use the official python API where possible).