]> granicus.if.org Git - python/commitdiff
Apply modified version of Collin Winter's patch #1478788
authorNick Coghlan <ncoghlan@gmail.com>
Mon, 29 May 2006 12:43:05 +0000 (12:43 +0000)
committerNick Coghlan <ncoghlan@gmail.com>
Mon, 29 May 2006 12:43:05 +0000 (12:43 +0000)
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.

Doc/Makefile.deps
Doc/lib/lib.tex
Doc/lib/libfunctools.tex [moved from Doc/lib/libfunctional.tex with 92% similarity]
Lib/test/test_functools.py [moved from Lib/test/test_functional.py with 98% similarity]
Misc/NEWS
Modules/_functoolsmodule.c [moved from Modules/functionalmodule.c with 95% similarity]
PC/VC6/pythoncore.dsp
PC/config.c
PCbuild/pythoncore.vcproj
setup.py

index 11c6de0414e83f3b8bc2deb29006a52dc8df1477..2fc3250ce486538b0208cac5862ca42666e0e72b 100644 (file)
@@ -262,6 +262,7 @@ LIBFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \
        lib/libsimplexmlrpc.tex \
        lib/libdocxmlrpc.tex \
        lib/libpyexpat.tex \
+       lib/libfunctools.tex \
        lib/xmldom.tex \
        lib/xmldomminidom.tex \
        lib/xmldompulldom.tex \
index cf657c3d1bd0a7b3c9622306e13457cf00be7762..0691179acb5d3474839e6fb19919e170a696c936 100644 (file)
@@ -129,8 +129,8 @@ and how to embed it in other applications.
 % Functions, Functional, Generators and Iterators
 % XXX intro functional
 \input{libitertools}
-\input{libfunctional}
-\input{liboperator}       % from runtime - better with itertools and functional
+\input{libfunctools}
+\input{liboperator}       % from runtime - better with itertools and functools
 
 
 % =============
similarity index 92%
rename from Doc/lib/libfunctional.tex
rename to Doc/lib/libfunctools.tex
index 9218454fe3e43e1b50c0a064565ddaa76d19f267..a25a23a4b83b2564e4a5dae9c71e500fc6a7e723 100644 (file)
@@ -1,7 +1,7 @@
-\section{\module{functional} ---
+\section{\module{functools} ---
          Higher order functions and operations on callable objects.}
 
-\declaremodule{standard}{functional}           % standard library, in Python
+\declaremodule{standard}{functools}            % standard library, in Python
 
 \moduleauthor{Peter Harris}{scav@blueyonder.co.uk}
 \moduleauthor{Raymond Hettinger}{python@rcn.com}
 
 \versionadded{2.5}
 
-The \module{functional} module is for higher-order functions: functions
+The \module{functools} module is for higher-order functions: functions
 that act on or return other functions. In general, any callable object can
 be treated as a function for the purposes of this module.
 
 
-The \module{functional} module defines the following function:
+The \module{functools} module defines the following function:
 
 \begin{funcdesc}{partial}{func\optional{,*args}\optional{, **keywords}}
 Return a new \class{partial} object which when called will behave like
similarity index 98%
rename from Lib/test/test_functional.py
rename to Lib/test/test_functools.py
index 5078a2e94f18ec0e56c05da19a7c533aa67ac883..609e8f463d676d57e14863e96251864af4f03ead 100644 (file)
@@ -1,4 +1,4 @@
-import functional
+import functools
 import unittest
 from test import test_support
 from weakref import proxy
@@ -21,7 +21,7 @@ def capture(*args, **kw):
 
 class TestPartial(unittest.TestCase):
 
-    thetype = functional.partial
+    thetype = functools.partial
 
     def test_basic_examples(self):
         p = self.thetype(capture, 1, 2, a=10, b=20)
@@ -140,7 +140,7 @@ class TestPartial(unittest.TestCase):
         join = self.thetype(''.join)
         self.assertEqual(join(data), '0123456789')
 
-class PartialSubclass(functional.partial):
+class PartialSubclass(functools.partial):
     pass
 
 class TestPartialSubclass(TestPartial):
index 90407d6386736ab55150d620a12a46cecc2ff170..24eb83571e409d27f77c22e4a0798e702209c0b9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -4,10 +4,10 @@ Python News
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
-What's New in Python 2.5 alpha 3?
+What's New in Python 2.5 beta 1?
 =================================
 
-*Release date: XX-MAY-2006*
+*Release date: XX-JUN-2006*
 
 Core and builtins
 -----------------
@@ -62,6 +62,11 @@ Core and builtins
 Extension Modules
 -----------------
 
+- Patch #1478788 (modified version): The functional extension module has
+  been renamed to _functools and a functools Python wrapper module added.
+  This provides a home for additional function related utilities that are
+  not specifically about functional programming. See PEP 309.
+
 - Patch #1493701: performance enhancements for struct module.
 
 - Patch #1490224: time.altzone is now set correctly on Cygwin.
@@ -82,6 +87,7 @@ Extension Modules
 - Calling Tk_Init twice is refused if the first call failed as that
   may deadlock.
 
+
 Library
 -------
 
@@ -142,6 +148,8 @@ Tools
 Documentation
 -------------
 
+
+
 What's New in Python 2.5 alpha 2?
 =================================
 
similarity index 95%
rename from Modules/functionalmodule.c
rename to Modules/_functoolsmodule.c
index 38ef43a71931c7dbc35849cf49c55b2f504e3ff4..54abb89d81de235a0397df37e00f287e3f031850 100644 (file)
@@ -2,10 +2,10 @@
 #include "Python.h"
 #include "structmember.h"
 
-/* Functional module written and maintained 
+/* _functools module written and maintained 
    by Hye-Shik Chang <perky@FreeBSD.org>
    with adaptations by Raymond Hettinger <python@rcn.com>
-   Copyright (c) 2004, 2005 Python Software Foundation.
+   Copyright (c) 2004, 2005, 2006 Python Software Foundation.
    All rights reserved.
 */
 
@@ -199,7 +199,7 @@ static PyGetSetDef partial_getsetlist[] = {
 static PyTypeObject partial_type = {
        PyObject_HEAD_INIT(NULL)
        0,                              /* ob_size */
-       "functional.partial",           /* tp_name */
+       "functools.partial",            /* tp_name */
        sizeof(partialobject),          /* tp_basicsize */
        0,                              /* tp_itemsize */
        /* methods */
@@ -245,14 +245,14 @@ static PyTypeObject partial_type = {
 /* module level code ********************************************************/
 
 PyDoc_STRVAR(module_doc,
-"Tools for functional programming.");
+"Tools that operate on functions.");
 
 static PyMethodDef module_methods[] = {
        {NULL,          NULL}           /* sentinel */
 };
 
 PyMODINIT_FUNC
-initfunctional(void)
+init_functools(void)
 {
        int i;
        PyObject *m;
@@ -262,7 +262,7 @@ initfunctional(void)
                NULL
        };
 
-       m = Py_InitModule3("functional", module_methods, module_doc);
+       m = Py_InitModule3("_functools", module_methods, module_doc);
        if (m == NULL)
                return;
 
index cf3200c9cef2cdece3577dc28866809ea1096805..ec2ec3ea1dc9bdde71309894fe30818544194a22 100644 (file)
@@ -313,7 +313,7 @@ SOURCE=..\..\Objects\funcobject.c
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\Modules\functionalmodule.c\r
+SOURCE=..\..\Modules\_functoolsmodule.c\r
 # End Source File\r
 # Begin Source File\r
 \r
index be11d3f8dcb7c1a11e1194fc862390c869333d85..b832d7c64fe5729d50a23bd51ec008640d7d9d84 100644 (file)
@@ -54,7 +54,7 @@ extern void initparser(void);
 extern void init_winreg(void);
 extern void init_struct(void);
 extern void initdatetime(void);
-extern void initfunctional(void);
+extern void init_functools(void);
 extern void initzlib(void);
 
 extern void init_multibytecodec(void);
@@ -132,7 +132,7 @@ struct _inittab _PyImport_Inittab[] = {
        {"_winreg", init_winreg},
        {"_struct", init_struct},
        {"datetime", initdatetime},
-       {"functional", initfunctional},
+       {"_functools", init_functools},
 
        {"xxsubtype", initxxsubtype},
        {"zipimport", initzipimport},
index c37e9b933d2526a574764fdf1e734a7c5ad2a80e..bb9f7af1b73b6c149d785ee019ee988a8298c4e7 100644 (file)
                        RelativePath="..\Objects\funcobject.c">
                </File>
                <File
-                       RelativePath="..\Modules\functionalmodule.c">
-               </File>
-               <File
-                       RelativePath="..\Modules\functionalmodule.c">
+                       RelativePath="..\Modules\_functoolsmodule.c">
                </File>
                <File
                        RelativePath="..\Python\future.c">
index 0abafd94d4e61d38b3de2fa1a8de9ab5b6d7d08e..9b2fac4b613c9e6d26cca2ba0ef796dd21f21273 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -377,8 +377,8 @@ class PyBuildExt(build_ext):
         exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
         # operator.add() and similar goodies
         exts.append( Extension('operator', ['operator.c']) )
-        # functional
-        exts.append( Extension("functional", ["functionalmodule.c"]) )
+        # _functools
+        exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
         # Python C API test module
         exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
         # profilers (_lsprof is for cProfile.py)