Skip to content

Commit 7422f94

Browse files
committed
Explicitly define timeit context
A possible fix for #1145.
1 parent 27c6be1 commit 7422f94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_blob.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,26 @@ def test_insert_longblob_32bit(schema_any, enable_feature_32bit_dims):
225225
def test_datetime_serialization_speed():
226226
# If this fails that means for some reason deserializing/serializing
227227
# np arrays of np.datetime64 types is now slower than regular arrays of datetime
228+
assert not dj.blob.use_32bit_dims, "32 bit dims should be off for this test"
229+
context = dict(
230+
np=np,
231+
datetime=datetime,
232+
pack=pack,
233+
unpack=unpack,
234+
)
228235

229236
optimized_exe_time = timeit.timeit(
230237
setup="myarr=pack(np.array([np.datetime64('2022-10-13 03:03:13') for _ in range(0, 10000)]))",
231238
stmt="unpack(myarr)",
232239
number=10,
233-
globals=globals(),
240+
globals=context
234241
)
235242
print(f"np time {optimized_exe_time}")
236243
baseline_exe_time = timeit.timeit(
237244
setup="myarr2=pack(np.array([datetime(2022,10,13,3,3,13) for _ in range (0, 10000)]))",
238245
stmt="unpack(myarr2)",
239246
number=10,
240-
globals=globals(),
247+
globals=context
241248
)
242249
print(f"python time {baseline_exe_time}")
243250

0 commit comments

Comments
 (0)