Skip to content

Commit e507078

Browse files
PYTHON-5679 Optimize ObjectId.__str__() (#2657)
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
1 parent 60289f0 commit e507078

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

bson/objectid.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""Tools for working with MongoDB ObjectIds."""
1616
from __future__ import annotations
1717

18-
import binascii
1918
import datetime
2019
import os
2120
import struct
@@ -234,7 +233,7 @@ def __setstate__(self, value: Any) -> None:
234233
self.__id = oid
235234

236235
def __str__(self) -> str:
237-
return binascii.hexlify(self.__id).decode()
236+
return self.__id.hex()
238237

239238
def __repr__(self) -> str:
240239
return f"ObjectId('{self!s}')"

0 commit comments

Comments
 (0)