mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	 9bfd2bf5ed
			
		
	
	
		9bfd2bf5ed
		
	
	
	
	
		
			
			Py_FatalError() from module initialization functions. The importing mechanism already checks for PyErr_Occurred() after module importation and it Does The Right Thing. Unfortunately, the following either were not compiled or tested by the regression suite, due to issues with my development platform: almodule.c cdmodule.c mpzmodule.c puremodule.c timingmodule.c
		
			
				
	
	
		
			75 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * Author: George V. Neville-Neil
 | |
|  */
 | |
| 
 | |
| #include "Python.h"
 | |
| 
 | |
| /* Our stuff... */
 | |
| #include "timing.h"
 | |
| 
 | |
| static PyObject *
 | |
| start_timing(PyObject *self, PyObject *args)
 | |
| {
 | |
| 	if (!PyArg_Parse(args, ""))
 | |
| 		return NULL;
 | |
| 
 | |
| 	Py_INCREF(Py_None);
 | |
| 	BEGINTIMING;
 | |
| 	return Py_None;
 | |
| }
 | |
| 
 | |
| static PyObject *
 | |
| finish_timing(PyObject *self, PyObject *args)
 | |
| {
 | |
| 	if (!PyArg_Parse(args, ""))
 | |
| 		return NULL;
 | |
| 
 | |
| 	ENDTIMING    
 | |
| 	Py_INCREF(Py_None);
 | |
| 	return Py_None;
 | |
| }
 | |
| 
 | |
| static PyObject *
 | |
| seconds(PyObject *self, PyObject *args)
 | |
| {
 | |
| 	if (!PyArg_Parse(args, ""))
 | |
| 		return NULL;
 | |
| 
 | |
| 	return PyInt_FromLong(TIMINGS);
 | |
| 
 | |
| }
 | |
| 
 | |
| static PyObject *
 | |
| milli(PyObject *self, PyObject *args)
 | |
| {
 | |
| 	if (!PyArg_Parse(args, ""))
 | |
| 		return NULL;
 | |
| 
 | |
| 	return PyInt_FromLong(TIMINGMS);
 | |
| 
 | |
| }
 | |
| static PyObject *
 | |
| micro(PyObject *self, PyObject *args)
 | |
| {
 | |
| 	if (!PyArg_Parse(args, ""))
 | |
| 		return NULL;
 | |
| 
 | |
| 	return PyInt_FromLong(TIMINGUS);
 | |
| 
 | |
| }
 | |
| 
 | |
| 
 | |
| static PyMethodDef timing_methods[] = {
 | |
| 	{"start",   start_timing},
 | |
| 	{"finish",  finish_timing},
 | |
| 	{"seconds", seconds},
 | |
| 	{"milli",   milli},
 | |
| 	{"micro",   micro},
 | |
| 	{NULL,      NULL}
 | |
| };
 | |
| 
 | |
| 
 | |
| DL_EXPORT(void) inittiming(void)
 | |
| {
 | |
| 	(void)Py_InitModule("timing", timing_methods);
 | |
| }
 |