chore: Add more benchmarks#146
Conversation
|
Not exactly this PR, but the previous performance improvement PR added sped up bt_json.py. However if a list subclass is given as argument this new fast version doesn't behave as expected: import dataclasses, sys, os
from braintrust.bt_json import bt_safe_deep_copy
class TaggedList(list): pass
@dataclasses.dataclass
class Point: x: float; y: float
# Plain list: dataclass → dict. TaggedList: dataclass → str (regression).
print(bt_safe_deep_copy([Point(1, 2)])) # [{'x': 1, 'y': 2}] ✓
print(bt_safe_deep_copy(TaggedList([Point(1, 2)])))# ['Point(x=1, y=2)'] ✗And it behaves correctly before the performance improvement change. - elif tv is list or tv is tuple:
+ elif tv is list or tv is tuple or isinstance(v, (list, tuple)): |
yeah that's a regression. Feel free to open a gh issue, we can fix as a follow up
nope, we set |
| batch_items( | ||
| _BATCH_STRINGS, | ||
| batch_max_num_bytes=_ITEM_SIZE * 15, | ||
| get_byte_size=lambda s: len(s.encode()), |
There was a problem hiding this comment.
Move the function definition outside the function body so function creating time isn't counted by pyperf?
Cedric / ViaDézo1er (viadezo1er)
left a comment
There was a problem hiding this comment.
Anyway good to merge this is just nitpicking
Adding a few more benchmarks so I can burn anthropic tokens on pi auto research over night.