msl.examples.loadlib.cpp64 module
Communicates with cpp_lib32 via the Cpp32
class.
Example of a module that can be executed within a 64-bit Python interpreter which can
communicate with a 32-bit library, cpp_lib32, that is hosted
by a 32-bit Python server, cpp32
. A 64-bit process cannot load a
32-bit library and therefore inter-process communication is used to
interact with a 32-bit library from a 64-bit process.
Cpp64
is the 64-bit client and Cpp32
is the 32-bit server for inter-process communication.
- class msl.examples.loadlib.cpp64.Cpp64
Bases:
Client64
Communicates with a 32-bit C++ library, cpp_lib32.
This class demonstrates how to communicate with a 32-bit C++ library if an instance of this class is created within a 64-bit Python interpreter.
- subtract(a, b)
Subtract two floating-point numbers (‘float’ refers to the C++ data type).
See the corresponding 32-bit
subtract()
method.
- add_or_subtract(a, b, do_addition)
Add or subtract two floating-point numbers (‘double’ refers to the C++ data type).
See the corresponding 32-bit
add_or_subtract()
method.
- scalar_multiply(a, xin)
Multiply each element in an array by a number.
See the corresponding 32-bit
scalar_multiply()
method.
- reverse_string_v1(original)
Reverse a string (version 1).
In this method Python allocates the memory for the reversed string and passes the string to C++.
See the corresponding 32-bit
reverse_string_v1()
method.
- reverse_string_v2(original)
Reverse a string (version 2).
In this method C++ allocates the memory for the reversed string and passes the string to Python.
See the corresponding 32-bit
reverse_string_v2()
method.
- distance_4_points(points)
Calculates the total distance connecting 4
Point
’s.See the corresponding 32-bit
distance_4_points()
method.- Parameters:
points (FourPoints) – The points to use to calculate the total distance. Since points is a struct that is a fixed size we can pass the
ctypes.Structure
object directly from 64-bit Python to the 32-bit Python. Thectypes
module on the 32-bit server can load thepickle
’dctypes.Structure
.- Returns:
The total distance connecting the 4 points.
- Return type:
- circumference(radius, n)
Estimates the circumference of a circle.
This method calls the
distance_n_points
function in cpp_lib32.See the corresponding 32-bit
circumference()
method.