Use of StringIO vs cStringIO in standard modules

Hrvoje Niksic hniksic at srce.hr
Thu Jun 3 05:56:36 EDT 1999


I noticed that many standard modules use StringIO and not cStringIO,
although they don't need subclassing.  Is this intentional?

For example, base64.py uses StringIO to implement encodestring() and
decodestring().  Since both functions write to output line by line, I
imagine the performance hit of StringIO vs cStringIO might be
non-negligible.

Furthermore, is there a particular reason for maintaining two parallel
StringIO implementations?  If subclassing is the reason, I assume it
would be trivial to rewrite StringIO to encapsulate cStringIO the same 
way that UserDict encapsulates dictionary objects.




More information about the Python-list mailing list