expanded ClassEncoder in Python API