On Dec 28, 2007 12:56 PM, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > On Dec 28, 2007 2:47 PM, Brett Cannon <[EMAIL PROTECTED]> wrote: > > No specific hints, but why do you feel you must implement the whole > > thing in C? Can't you just import 'io' in your StringIO code and make > > calls into the Python code? > > > > Honestly, I didn't really consider this as a possibility, since > TextIOWrapper only accepts bytes buffer, as far as I know. The other > obstacle is newline conversion has a fair amount of state that needs > to be managed at the API level. > > But, I thinking two better solutions. Could I add a "switch" to > TextIOWrapper to disable the encoding/decoding process for a unicode > buffer? Then, I could wrap my StringIO with TextIOWrapper without > adding any huge overhead.
I have no clue about this. > Otherwise, could I simply subclass my > StringIO and write the newlines conversion facilities in Python? > Definitely. Nothing says C re-implementations have to be a complete replacement. Just do the performance-critical stuff in C and everything else can just be Python code. It's easier to write and maintain. -Brett _______________________________________________ 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
