from sqlalchemy.orm import object_session
from sqlalchemy.orm.util import has_identity
transient:
object_session(obj) is None and not has_identity(obj)
detached:
object_session(obj) is None and has_identity(obj)
pending, persistent etc.
You've basically figured out the less public ways of doing the same thing.