31 """Determine which implementation of the protobuf API is used in this process.
43 _api_version = _api_implementation.api_version
48 raise ValueError(
'api_version=1 is no longer supported.')
51 _default_implementation_type = (
'cpp' if _api_version > 0
else 'python')
58 _implementation_type = os.getenv(
'PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION',
59 _default_implementation_type)
61 if _implementation_type !=
'python':
62 _implementation_type =
'cpp'
64 if 'PyPy' in sys.version
and _implementation_type ==
'cpp':
65 warnings.warn(
'PyPy does not work yet with cpp protocol buffers. '
66 'Falling back to the python implementation.')
67 _implementation_type =
'python'
86 _python_deterministic_proto_serialization =
True
88 _python_deterministic_proto_serialization =
False
96 return _implementation_type
100 """Never use! Only for protobuf benchmark."""
101 global _implementation_type
102 _implementation_type = implementation_type
112 return _python_deterministic_proto_serialization