Staging
v0.5.1
https://github.com/python/cpython
Revision 69b747b7358780c84d1cac1317bfb7d5baa4e6e3 authored by Amaury Forgeot d'Arc on 28 March 2008, 20:30:50 UTC, committed by Amaury Forgeot d'Arc on 28 March 2008, 20:30:50 UTC
Now "regrtest.py -R:: test_compile" is satisfied.

Will backport.
1 parent aa5fbdd
Raw File
Tip revision: 69b747b7358780c84d1cac1317bfb7d5baa4e6e3 authored by Amaury Forgeot d'Arc on 28 March 2008, 20:30:50 UTC
Fix a reference leak found by Georg, when compiling a class nested in another class.
Tip revision: 69b747b
timingmodule.c
/*
 * Author: George V. Neville-Neil
 */

#include "Python.h"

/* Our stuff... */
#include "timing.h"

static PyObject *
start_timing(PyObject *self)
{
	Py_INCREF(Py_None);
	BEGINTIMING;
	return Py_None;
}

static PyObject *
finish_timing(PyObject *self)
{
	ENDTIMING    
	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject *
seconds(PyObject *self)
{
	return PyInt_FromLong(TIMINGS);
}

static PyObject *
milli(PyObject *self)
{
	return PyInt_FromLong(TIMINGMS);
}

static PyObject *
micro(PyObject *self)
{
	return PyInt_FromLong(TIMINGUS);
}


static PyMethodDef timing_methods[] = {
	{"start",   (PyCFunction)start_timing, METH_NOARGS},
	{"finish",  (PyCFunction)finish_timing, METH_NOARGS},
	{"seconds", (PyCFunction)seconds, METH_NOARGS},
	{"milli",   (PyCFunction)milli, METH_NOARGS},
	{"micro",   (PyCFunction)micro, METH_NOARGS},
	{NULL,      NULL}
};


PyMODINIT_FUNC inittiming(void)
{
	(void)Py_InitModule("timing", timing_methods);
}
back to top