py/objstringio: If created from immutable object, follow copy on write policy.

Don't create copy of immutable object's contents until .write() is called
on BytesIO.
This commit is contained in:
Paul Sokolovsky
2017-06-05 23:54:21 +03:00
parent b24ccfc639
commit 07241cd37a
5 changed files with 70 additions and 3 deletions

View File

@@ -33,6 +33,8 @@ typedef struct _mp_obj_stringio_t {
vstr_t *vstr;
// StringIO has single pointer used for both reading and writing
mp_uint_t pos;
// Underlying object buffered by this StringIO
mp_obj_t ref_obj;
} mp_obj_stringio_t;
#endif // MICROPY_INCLUDED_PY_OBJSTRINGIO_H