PYTHON-5679 Optimize ObjectId.__str__() (#2657)
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
This commit is contained in:
parent
60289f0398
commit
e5070789cc
@ -15,7 +15,6 @@
|
||||
"""Tools for working with MongoDB ObjectIds."""
|
||||
from __future__ import annotations
|
||||
|
||||
import binascii
|
||||
import datetime
|
||||
import os
|
||||
import struct
|
||||
@ -234,7 +233,7 @@ class ObjectId:
|
||||
self.__id = oid
|
||||
|
||||
def __str__(self) -> str:
|
||||
return binascii.hexlify(self.__id).decode()
|
||||
return self.__id.hex()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"ObjectId('{self!s}')"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user