blob: ec6b5338f79a6cc5478127c09475315b8e68955e (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
"""
Internal objects to support the UUID adapters.
"""
# Copyright (C) 2025 The Psycopg Team
import uuid
# Re-exports
UUID = uuid.UUID
SafeUUID_unknown = uuid.SafeUUID.unknown
class _WritableUUID(UUID):
"""Temporary class, with the same memory layout of UUID, but writable.
This class must have the same memory layout of the UUID class, so we can
create one, setting the `int` attribute, and changing the `__class__`,
which should be faster than calling the complex UUID.__init__ machinery.
u = _WritableUUID()
u.is_safe = ...
u.int = ...
u.__class__ = UUID
"""
__slots__ = () # Give the class the same memory layout of the base clasee
__setattr__ = object.__setattr__ # make the class writable
|