Add better error reporting for MemoryErrors caused by str->float conversions.
[python.git] / Modules / timingmodule.c
blob0da5c6b763d771db7dcd276bbb3ae2075860d02e
1 /*
2 * Author: George V. Neville-Neil
3 */
5 #include "Python.h"
7 /* Our stuff... */
8 #include "timing.h"
10 static PyObject *
11 start_timing(PyObject *self)
13 Py_INCREF(Py_None);
14 BEGINTIMING;
15 return Py_None;
18 static PyObject *
19 finish_timing(PyObject *self)
21 ENDTIMING
22 Py_INCREF(Py_None);
23 return Py_None;
26 static PyObject *
27 seconds(PyObject *self)
29 return PyInt_FromLong(TIMINGS);
32 static PyObject *
33 milli(PyObject *self)
35 return PyInt_FromLong(TIMINGMS);
38 static PyObject *
39 micro(PyObject *self)
41 return PyInt_FromLong(TIMINGUS);
45 static PyMethodDef timing_methods[] = {
46 {"start", (PyCFunction)start_timing, METH_NOARGS},
47 {"finish", (PyCFunction)finish_timing, METH_NOARGS},
48 {"seconds", (PyCFunction)seconds, METH_NOARGS},
49 {"milli", (PyCFunction)milli, METH_NOARGS},
50 {"micro", (PyCFunction)micro, METH_NOARGS},
51 {NULL, NULL}
55 PyMODINIT_FUNC inittiming(void)
57 if (PyErr_WarnPy3k("the timing module has been removed in "
58 "Python 3.0; use time.clock() instead", 2) < 0)
59 return;
61 (void)Py_InitModule("timing", timing_methods);