[issue12778] JSON-serializing a large container takes too much memory

Antoine Pitrou report at bugs.python.org
Fri Aug 19 16:09:53 CEST 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

> I actually looked into doing this for issue #12134, but it didn't seem 
> so simple; Since C has no yield, I think the iterator would need to
> maintain its own stack to keep track of where it is in the object tree 
> it's encoding...

The encoder doesn't have to be turned into an iterator. It would just need to call a given callable (fp.write) at regular intervals and that would be enough to C-accelerate dump().

My patch actually provides a good foundation for this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12778>
_______________________________________


More information about the Python-bugs-list mailing list