New submission from Raymond Hettinger:

Currently, we have little to no control over the alignment of memory returned 
by the PyMem functions.   

I suggest variants such as PyMem_Alloc32(n) and PyMem_Alloc64(n) to return 
suitably aligned data blocks.

GNU C provides memalign() for this purpose:  
http://www.delorie.com/gnu/docs/glibc/libc_31.html
and the Microsoft C compiler has _aligned_malloc() for the same purpose: 
http://msdn.microsoft.com/en-us/library/8z34s9c6%28VS.80%29.aspx

A principal use case would be PyObject pointers where we want to keep all or 
most of the data fields in the same cache line (i.e. the fields for list, 
tuple, dict, and set objects).

Deques would benefit from having the deque blocks aligned to 64byte boundaries 
and never crossing page boundaries.  Set entries would benefit from 32byte 
alignment.

----------
components: Interpreter Core
messages: 196174
nosy: rhettinger
priority: normal
severity: normal
stage: needs patch
status: open
title: Add aligned memroy variants to the suite of PyMem functions/macros
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18835>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to