Python 3.9 is now generally available.

google.appengine.ext.db.to_dict

Convert model to dictionary.

model_instance Model instance for which to make dictionary.
dictionary dict instance or compatible to receive model values. The dictionary is not cleared of original values. Similar to using dictionary.update. If dictionary is None, a new dictionary instance is created and returned.

New dictionary appropriate populated with model instances values if entity is None, else entity.