unfortunately it changed dramatically between python 2 and 3, but there is a protocol by which objects implemented in C can support memory sharing. this could be used with file objects for example to dump a json stream straight to the file object's buffer rather than creating a PyString and calling .read() through python.
this would need to fall back to current behavior as pure-python file-like objects should be supported.
see http://docs.python.org/release/2.6.5/c-api/typeobj.html#buffer-object-structures and http://docs.python.org/release/2.6.5/c-api/objbuffer.html