Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue3289] unnecessary call to time and localtime slows time.mktime

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 5, 2008, 9:13 AM

Post #1 of 2 (71 views)
Permalink
[issue3289] unnecessary call to time and localtime slows time.mktime

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>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 5, 2008, 12:36 PM

Post #2 of 2 (61 views)
Permalink
[issue3289] unnecessary call to time and localtime slows time.mktime [In reply to]

Facundo Batista <facundo[at]taniquetil.com.ar> added the comment:

Commited in r64745. Thanks for this patch!

----------
nosy: +facundobatista
resolution: -> accepted
status: open -> closed

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3289>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.