import pandas as pd import numpy as np from datetime import datetime import random from memray import Tracker
defgenerate_a_lot_datetime(n: int = 1_000_000): with Tracker("generate_a_lot_datetime.bin"): res = [] for i inrange(n): res.append(datetime(2022, random.randint(1, 12), random.randint(1, 28), 1, 1, 1, i%1000))
return res
defgenerate_a_lot_datetime64(n: int = 1_000_000):
with Tracker("generate_a_lot_datetime64.bin"): res = [] for i inrange(n): res.append(np.datetime64(f"2022-{random.randint(1, 12):02d}-{random.randint(1, 28):02d}T01:02:03.123"))
return res
defgenerate_a_lot_Timestamp(n: int = 1_000_000):
with Tracker("generate_a_lot_Timestamp.bin"): res = [] for i inrange(n): res.append(pd.Timestamp(f"2022-{random.randint(1, 12):02d}-{random.randint(1, 28):02d}T01:02:03.123"))
return res
if __name__ == "__main__": res = generate_a_lot_datetime()