[Python-checkins] r84555 - python/branches/py3k/Tools/iobench/iobench.py

antoine.pitrou python-checkins at python.org
Mon Sep 6 14:36:55 CEST 2010


Author: antoine.pitrou
Date: Mon Sep  6 14:36:55 2010
New Revision: 84555

Log:
Add an option to choose the IO module under test (allows to bench
e.g. the pure Python implementation in _pyio).



Modified:
   python/branches/py3k/Tools/iobench/iobench.py

Modified: python/branches/py3k/Tools/iobench/iobench.py
==============================================================================
--- python/branches/py3k/Tools/iobench/iobench.py	(original)
+++ python/branches/py3k/Tools/iobench/iobench.py	Mon Sep  6 14:36:55 2010
@@ -427,6 +427,9 @@
                       action="store", dest="newlines", default='lf',
                       help="line endings for text tests "
                            "(one of: {lf (default), cr, crlf, all})")
+    parser.add_option("-m", "--io-module",
+                      action="store", dest="io_module", default=None,
+                      help="io module to test (default: builtin open())")
     options, args = parser.parse_args()
     if args:
         parser.error("unexpected arguments")
@@ -451,6 +454,9 @@
     if options.encoding:
         TEXT_ENCODING = options.encoding
 
+    if options.io_module:
+        globals()['open'] = __import__(options.io_module, {}, {}, ['open']).open
+
     prepare_files()
     run_all_tests(test_options)
 


More information about the Python-checkins mailing list