diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 6ec572575..ddcd6407b 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -3913,13 +3913,13 @@ class Go(object):

-The generated code when using -fastproxy is: +The generated proxy class when using -fastproxy is:

 %module example
-class Go(_object):
+class Go(object):
     callme0 = _swig_new_instance_method(_example.Go_callme0)
     callme4 = _swig_new_instance_method(_example.Go_callme4)
     callme8 = _swig_new_instance_method(_example.Go_callme8)
@@ -3930,37 +3930,70 @@ class Go(_object):
 

where _swig_new_instance_method adds the method to the proxy class via C API calls. The overhead calling into C/C++ from Python is reduced slightly using -fastproxy. -Below are some timings in microseconds calling the 3 functions in the example above: +Below are some timings in microseconds calling the 3 functions in the example above. +Also included in the table for comparison is using the -builtin option covered in the +Built-in Types.

- - + + + - - + + + - - + + + - - + + +
Method nameWithout -fastproxyWith -fastproxyDefault-fastproxy-builtin
callme00.570.480.150.090.07
callme40.640.540.260.160.14
callme80.730.570.320.200.17

-Although the -fastproxy option results in faster code, the generated proxy code is not as user-friendly +Although the -fastproxy option results in faster code over the default, the generated proxy code is not as user-friendly as docstring/doxygen comments and functions with default values are not visible in the generated Python proxy class. +The -olddefs option can rectify this.

+

+The generated proxy class for the example above when using -fastproxy -olddefs is: +

+ +
+
+class Go(object):
+    def callme0(self):
+        return _example.Go_callme0(self)
+    callme0 = _swig_new_instance_method(_example.Go_callme0)
+
+    def callme4(self, a, b, c, d):
+        return _example.Go_callme4(self, a, b, c, d)
+    callme4 = _swig_new_instance_method(_example.Go_callme4)
+
+    def callme8(self, a, b, c, d, e, f, g, i):
+        return _example.Go_callme8(self, a, b, c, d, e, f, g, i)
+    callme8 = _swig_new_instance_method(_example.Go_callme8)
+    ...
+
+
+ +

+The class defines each method in two different ways. The first definition is replaced by the second definition and so the second definition is the one used when the method is called. +While this possibly provides the best of both worlds, the time to import the module will be slighly slower when the class is defined due to the additional method definitions. +

38.7 Tips and techniques