2007/10/25, Facundo Batista <[EMAIL PROTECTED]>:

> BTW, I'll leave the optimization of importing strptime one time,
> there's no reason to try to import it everytime strptime() is called.

No, I'm not. In consideration to the possible warning raised by Brett,
I won't commit the change (it does not fix anything, just a marginal
optimization, so there's no enough reason to bring a possible issue).

For the record, I'm attaching the would-be patch.

Thank you all!

Regards,

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
Index: Modules/timemodule.c
===================================================================
--- Modules/timemodule.c	(revisión: 58658)
+++ Modules/timemodule.c	(copia de trabajo)
@@ -98,6 +98,9 @@
 /* For Y2K check */
 static PyObject *moddict;
 
+/* This will be initializied at module init time */
+static PyObject *strptime_module;
+
 /* Exposed in timefuncs.h. */
 time_t
 _PyTime_DoubleToTimet(double x)
@@ -514,13 +517,11 @@
 static PyObject *
 time_strptime(PyObject *self, PyObject *args)
 {
-    PyObject *strptime_module = PyImport_ImportModule("_strptime");
     PyObject *strptime_result;
 
     if (!strptime_module)
         return NULL;
     strptime_result = PyObject_CallMethod(strptime_module, "strptime", "O", args);
-    Py_DECREF(strptime_module);
     return strptime_result;
 }
 
@@ -848,6 +849,8 @@
 	Py_INCREF(&StructTimeType);
 	PyModule_AddObject(m, "struct_time", (PyObject*) &StructTimeType);
 	initialized = 1;
+
+    strptime_module = PyImport_ImportModule("_strptime");
 }
 
 
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to