This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nother_jnelson
Recipients nother_jnelson
Date 2008-07-05.16:13:27
SpamBayes Score 0.001413815
Marked as misclassified No
Message-id <1215274409.55.0.482276845315.issue3289@psf.upfronthosting.co.za>
In-reply-to
Content
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);
History
Date User Action Args
2008-07-05 16:13:29nother_jnelsonsetspambayes_score: 0.00141381 -> 0.001413815
recipients: + nother_jnelson
2008-07-05 16:13:29nother_jnelsonsetspambayes_score: 0.00141381 -> 0.00141381
messageid: <1215274409.55.0.482276845315.issue3289@psf.upfronthosting.co.za>
2008-07-05 16:13:28nother_jnelsonlinkissue3289 messages
2008-07-05 16:13:27nother_jnelsoncreate