[issue3289] unnecessary call to time and localtime slows time.mktime
Jon Nelson
report at bugs.python.org
Sat Jul 5 18:13:29 CEST 2008
New submission from Jon Nelson <jnelson+python at jamponi.net>:
Basically, time.mktime calls time and localtime, and then overwrites
those results. Removing these unnecessary calls results in a fairly
noticeable speedup, lower double-digit percentile improvements for
applications that do time parsing, for example.
The patch below is for 2.5, but should apply to more recent versions.
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index be02ec2..dad235a 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -599,8 +599,6 @@ time_mktime(PyObject *self, PyObject *tup)
{
struct tm buf;
time_t tt;
- tt = time(&tt);
- buf = *localtime(&tt);
if (!gettmarg(tup, &buf))
return NULL;
tt = mktime(&buf);
----------
components: Extension Modules
messages: 69283
nosy: nother_jnelson
severity: normal
status: open
title: unnecessary call to time and localtime slows time.mktime
type: performance
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3289>
_______________________________________
More information about the Python-bugs-list
mailing list