[Python-checkins] r53062 - sandbox/trunk/import_in_py/importbench.py

brett.cannon python-checkins at python.org
Tue Dec 19 03:11:05 CET 2006


Author: brett.cannon
Date: Tue Dec 19 03:11:04 2006
New Revision: 53062

Modified:
   sandbox/trunk/import_in_py/importbench.py
Log:
Add docstring for the module.


Modified: sandbox/trunk/import_in_py/importbench.py
==============================================================================
--- sandbox/trunk/import_in_py/importbench.py	(original)
+++ sandbox/trunk/import_in_py/importbench.py	Tue Dec 19 03:11:04 2006
@@ -1,3 +1,24 @@
+"""Benchmark importing.
+
+There are two aspects to importing that these benchmarks should cover.  One is
+the importing of various types of modules (such as extension modules, frozen
+modules, etc.).  The other aspect is the general mechanism of importing (such as
+walking sys.path, using path_hooks, etc.).
+
+In general, though, one encompasses the other.  By minimizing the entries in
+sys.path and sys.meta_path when benchmarking the import of different types of
+files you also inadvertently benchmark the fundamental import machinery as well.
+This means that only extreme cases of the import machinery need to be explicitly
+tested.
+
+Another thing to keep in mind is expected changed in Py3K in terms of the
+'level' argument.  Since Py3K is a definite target for this code the 'level'
+value should be set properly and not be allowed to default to -1.  While
+benchmarking the classic relative import style would be helpful it should be
+its own benchmark.
+
+"""
+#XXX make sure all code goes repetitions, iterations (and probably with those names).
 from py_compile import compile as compile_to_pyc
 import os
 import StringIO
@@ -71,7 +92,7 @@
 
 @save_import_state
 def bench_sys_modules(times, repeat):
-    """Benchmark returning a modules from sys.modules."""
+    """Benchmark returning a module from sys.modules."""
     sys.path = []
     sys.meta_path = []
     sys.path_importer_cache.clear()
@@ -174,4 +195,5 @@
 
             
 if __name__ == '__main__':
+# XXX support specifying number of repetitions and iterations from the command-line.
     main(sys.argv[1:] if len(sys.argv) > 1 else None)


More information about the Python-checkins mailing list