diff -r 4034c96a98a7 Modules/gcmodule.c --- a/Modules/gcmodule.c Fri May 23 14:09:34 2014 +0300 +++ b/Modules/gcmodule.c Fri May 23 09:45:23 2014 -0400 @@ -25,6 +25,7 @@ #include "Python.h" #include "frameobject.h" /* for PyFrame_ClearFreeList */ +#include "pytime.h" /* for _PyTime_gettimeofday */ /* Get an object's GC head */ #define AS_GC(o) ((PyGC_Head *)(o)-1) @@ -166,7 +167,6 @@ DEBUG_UNCOLLECTABLE | \ DEBUG_SAVEALL static int debug; -static PyObject *tmod = NULL; /* Running stats per generation */ struct gc_generation_stats { @@ -898,19 +898,9 @@ get_time(void) { double result = 0; - if (tmod != NULL) { - _Py_IDENTIFIER(time); - - PyObject *f = _PyObject_CallMethodId(tmod, &PyId_time, NULL); - if (f == NULL) { - PyErr_Clear(); - } - else { - if (PyFloat_Check(f)) - result = PyFloat_AsDouble(f); - Py_DECREF(f); - } - } + _PyTime_timeval tval; + _PyTime_gettimeofday(&tval); + result = tval.tv_sec + tval.tv_usec * 1e-6; return result; } @@ -1587,11 +1577,6 @@ * reset to 0 before calling collect which trips up * the import and triggers an assertion. */ - if (tmod == NULL) { - tmod = PyImport_ImportModuleNoBlock("time"); - if (tmod == NULL) - PyErr_Clear(); - } #define ADD_INT(NAME) if (PyModule_AddIntConstant(m, #NAME, NAME) < 0) return NULL ADD_INT(DEBUG_STATS); @@ -1681,7 +1666,6 @@ _PyGC_Fini(void) { Py_CLEAR(callbacks); - Py_CLEAR(tmod); } /* for debugging */