[Python-checkins] r55974 - python/branches/cpy_merge/Lib/io.py
alexandre.vassalotti
python-checkins at python.org
Thu Jun 14 22:32:52 CEST 2007
Author: alexandre.vassalotti
Date: Thu Jun 14 22:32:50 2007
New Revision: 55974
Modified:
python/branches/cpy_merge/Lib/io.py
Log:
Use the faster _string_io/_bytes_io if available.
Modified: python/branches/cpy_merge/Lib/io.py
==============================================================================
--- python/branches/cpy_merge/Lib/io.py (original)
+++ python/branches/cpy_merge/Lib/io.py Thu Jun 14 22:32:50 2007
@@ -575,7 +575,7 @@
return True
-class BytesIO(_MemoryIOMixin):
+class _BytesIO(_MemoryIOMixin):
"""Buffered I/O implementation using a bytes buffer, like StringIO."""
@@ -587,6 +587,12 @@
buffer += inital_bytes
_MemoryIOMixin.__init__(self, buffer)
+# Use the faster implementation if available
+try:
+ from _bytes_io import BytesIO
+except ImportError:
+ BytesIO = _BytesIO
+
# XXX This should inherit from TextIOBase
class StringIO(_MemoryIOMixin):
@@ -612,6 +618,12 @@
def readinto(self, b: bytes) -> int:
self._unsupported("readinto")
+# Use the faster implementation if available
+try:
+ from _string_io import StringIO
+except ImportError:
+ StringIO = _StringIO
+
class BufferedReader(_BufferedIOMixin):
More information about the Python-checkins
mailing list