-
Type: Improvement
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
When the c extensions are not installed the pure Python BSON decoder performs unessecary memory copies. For example when decoding a string we first copy the bytes of the string (data[position:end]), and then decode those bytes to a Python string/unicode instance:
return _utf_8_decode(data[position:end], opts.unicode_decode_error_handler, True)[0], end + 1
https://github.com/mongodb/mongo-python-driver/blob/3.7.1/bson/__init__.py#L182
We can use a memoryview to avoid the need to create a temporary byte copy.
Credit to behackett for the idea.
- duplicates
-
PYTHON-1785 Provide utility encode and decode methods in BSON module
- Closed