On Fri, 20 Feb 2015 08:50:10 +0000 raymond.hettinger <python-check...@python.org> wrote: > https://hg.python.org/cpython/rev/0ba4bcc0a7a6 > changeset: 94696:0ba4bcc0a7a6 > user: Raymond Hettinger <pyt...@rcn.com> > date: Fri Feb 20 00:50:04 2015 -0800 > summary: > Improve struct cache locality by bring commonly accessed fields close > together. > > files: > Modules/_randommodule.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > > diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c > --- a/Modules/_randommodule.c > +++ b/Modules/_randommodule.c > @@ -78,8 +78,8 @@ > > typedef struct { > PyObject_HEAD > + int index; > unsigned long state[N]; > - int index; > } RandomObject;
I may be missing something something, but I don't see how that improves cache locality. The index is only ever looked up when the state is also looked up, and since the state is used sequentially there are equal chances for the state lookup to be near the end rather than near the front. Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com