Python have not consistency in this case. Json and pickle modules follow my idea, but a lot of other module follow your suggestion...
I prefer your solution, definitely.

Some other examples in the Python community:
https://github.com/mitsuhiko/jinja2/blob/master/jinja2/optimizer.py
https://bitbucket.org/cherrypy/cherrypy/src/799f39c23c8d9982f3b0523a9234f518ec3407ae/cherrypy/lib/encoding.py?at=default

(They have not the same objectives, just for naming examples)