This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import time | |
| def random_int64(): | |
| '''Generate a random 64-bit signed integer, with timestamp embedded in the higher 42 bits.''' | |
| CUSTOM_EPOCH = 1735689600 # 2025/01/01 00:00:00 UTC | |
| HIGH_42BIT_MASK = 0x7FFFFFFFFFC00000 # hex((2 ** 41 - 1) << 22) | |
| LOW_22BIT_MASK = 0x3FFFFF # hex(2 ** 22 - 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # USAGE: | |
| # 1) Append this snippet to https://github.com/python/cpython/blob/v3.9.21/Tools/gdb/libpython.py | |
| # 2) In GDB run `source /path/to/libpython.py` | |
| # 3) In GDB run `py-enum-objects /path/to/output.txt` | |
| # | |
| class PyEnumObjects(gdb.Command): | |
| 'Enumerate all objects tracked by the garbage collector (Python 3.9+)' | |
| def __init__(self): | |
| super(PyEnumObjects, self).__init__( | |
| 'py-enum-objects', |