Unlike `Py_DECREF`, `Py_CLEAR` offers enhanced safety by checking if the object pointer is NULL before decrementing its reference count, and then setting the pointer to NULL afterward. This prevents dangerous use-after-free bugs and avoids arbitrary Python code execution on a deallocated object.