-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: BSON, Performance
-
None
-
None
-
Python Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Context
While working on PYTHON-5965, I found a performance win that affects the existing
bson. I measured about a 15% improvement on a spawn perf host on the standard bson tests.
{write_unicode}} (string values) and decode_and_write_pair (string keys) allocate a temporary bytes per element using PyUnicode_AsUTF8String.
Definition of done
- Switch to PyUnicode_AsUTF8AndSize, which returns a borrowed pointer into the string's cached UTF-8 buffer with no temporary allocation.
Pitfalls
The pointer is borrowed, so keep the source string alive until after the buffer write (else use-after-free)
- blocks
-
PYTHON-6109 Stable-ABI (abi3) wheels for Python 3.11+
-
- Needs Triage
-
- is blocked by
-
PYTHON-6096 Add BSON benchmarking regression test support
-
- Needs Triage
-