diff -r 3ce0102e4c1f Lib/copyreg.py --- a/Lib/copyreg.py Wed Oct 09 14:53:01 2013 +0200 +++ b/Lib/copyreg.py Wed Oct 09 16:16:33 2013 +0200 @@ -182,6 +182,19 @@ def clear_extension_cache(): _extension_cache.clear() +# The callbacks are registered here instead of the os module in order to +# remove the dependency on copyreg and to speed up the interpreter's startup +# time. + +import os + +if hasattr(os, "stat_result"): + pickle(os.stat_result, os._pickle_stat_result, os._make_stat_result) + +if hasattr(os, "statvfs_result"): + pickle(os.statvfs_result, os._pickle_statvfs_result, + os._make_statvfs_result) + # Standard extension code assignments # Reserved ranges diff -r 3ce0102e4c1f Lib/os.py --- a/Lib/os.py Wed Oct 09 14:53:01 2013 +0200 +++ b/Lib/os.py Wed Oct 09 16:16:33 2013 +0200 @@ -945,8 +945,7 @@ __all__.extend(["spawnlp", "spawnlpe"]) -import copyreg as _copyreg - +# used by copyreg def _make_stat_result(tup, dict): return stat_result(tup, dict) @@ -954,11 +953,6 @@ (type, args) = sr.__reduce__() return (_make_stat_result, args) -try: - _copyreg.pickle(stat_result, _pickle_stat_result, _make_stat_result) -except NameError: # stat_result may not exist - pass - def _make_statvfs_result(tup, dict): return statvfs_result(tup, dict) @@ -966,11 +960,6 @@ (type, args) = sr.__reduce__() return (_make_statvfs_result, args) -try: - _copyreg.pickle(statvfs_result, _pickle_statvfs_result, - _make_statvfs_result) -except NameError: # statvfs_result may not exist - pass # Supply os.popen() def popen(cmd, mode="r", buffering=-1):