Hi,

I written a short summary of the differences between the StringIO and
cStringIO modules.  I attached it as a patch for PEP-3108.

-- Alexandre
Index: pep-3108.txt
===================================================================
--- pep-3108.txt	(revision 56050)
+++ pep-3108.txt	(working copy)
@@ -434,9 +434,35 @@
 
   + Rename StringIO to stringio.
   + Rename cStringIO to _stringio.
-  + Semantic completeness of C implementation *not* verified.
 
+  The C implementation has a few shortcomings.  For example,
+  cStringIO.StringIO is a function, not a class.  This function
+  returns, if given a string argument, a StringI object. Otherwise, a
+  StringO object is returned.  StringI objects are read-only:
 
+     >>> s = cStringIO.StringIO("spam")
+     >>> s.write("eggs")
+     Traceback (most recent call last):
+       File "<stdin>", line 1, in <module>
+     AttributeError: 'cStringIO.StringI' object has no attribute 'write'
+
+  And since StringIO in cStringIO is function, it is not subclassable.
+  cStringIO doesn't support Unicode.  All arguments passed to
+  cStringIO methods need to be of type `str` or `buffer`.
+
+  There is few other trivial differences between the two
+  implementations.  The `getvalue()` method in cStringIO has an
+  optional argument. From the documentation:
+
+      getvalue([use_pos]) -- Get the string value.
+      If use_pos is specified and is a true value, then the string returned
+      will include only the text up to the current file position.
+
+  cStringIO also have a `reset()` method, which set the current file
+  position to the beginning.  Objects resulting from cStringIO are not
+  serializable by the pickle module (however this is non-trival to fix).
+
+
 No public, documented interface
 -------------------------------
 
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to