On Wed, 2022-01-19 at 20:49 +0100, Jerome Kieffer wrote: > On Wed, 19 Jan 2022 19:48:32 +0100 > Francesc Alted <fal...@gmail.com> wrote: > > > What puzzles me is that the timeit loops access `z` data 3*10000 > > times, which is plenty of time for doing the allocation (just > > should > > require just a single iteration). > > Hi all, > > Very interesting discussion ... IIRC, timeit does some clever tricks > like disabling the garbage collector, so for the first run of timeit,
Yes, but this will have no influence on the observation. (The following explanation applies to CPython and things are different on other Python implementations.) Timeit will disable the GC. But that does not mean that automatic memory management is disabled completely. It will have no affect on the code in question. Disabling the GC only disables complicated memory management: That is cleaning up reference circles. Such as a list containing itself, a class containing an attribute which contains itself, etc. Further, I suspect timeit is smart enough to allow running the GC between timing runs (i.e. at the setup stage). Cheers, Sebastian > I > suspect it does 10000 malloc (without associated free thus without > the > ability of recycling any of those buffers). > On the second run, those buffer were allocated previously and kept by > Python for re-use which could explain the faster run. > > This does not explain really the different between operating systems > observed. > > Cheers, > > Jerome > _______________________________________________ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ > Member address: sebast...@sipsolutions.net >
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com