[Python-checkins] cpython: Reuse us_per_second in delta_total_seconds.

alexander.belopolsky python-checkins at python.org
Sun Aug 4 21:19:59 CEST 2013


http://hg.python.org/cpython/rev/604e3199acc0
changeset:   85028:604e3199acc0
parent:      85025:fb7c6803ba70
user:        Alexander Belopolsky <alexander.belopolsky at gmail.com>
date:        Sun Aug 04 15:18:58 2013 -0400
summary:
  Reuse us_per_second in delta_total_seconds.

files:
  Modules/_datetimemodule.c |  10 +---------
  1 files changed, 1 insertions(+), 9 deletions(-)


diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -2252,22 +2252,14 @@
 {
     PyObject *total_seconds;
     PyObject *total_microseconds;
-    PyObject *one_million;
 
     total_microseconds = delta_to_microseconds((PyDateTime_Delta *)self);
     if (total_microseconds == NULL)
         return NULL;
 
-    one_million = PyLong_FromLong(1000000L);
-    if (one_million == NULL) {
-        Py_DECREF(total_microseconds);
-        return NULL;
-    }
-
-    total_seconds = PyNumber_TrueDivide(total_microseconds, one_million);
+    total_seconds = PyNumber_TrueDivide(total_microseconds, us_per_second);
 
     Py_DECREF(total_microseconds);
-    Py_DECREF(one_million);
     return total_seconds;
 }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list