#18868: a MemoryAllocator object for easier Cython memory management
-------------------------+-------------------------------------------------
Reporter: | Owner:
ncohen | Status: needs_work
Type: | Milestone: sage-6.8
enhancement | Resolution:
Priority: major | Merged in:
Component: | Reviewers:
cython | Work issues:
Keywords: | Commit:
Authors: | 27231756748e4743df056783f524c66099189ccf
Nathann Cohen | Stopgaps:
Report Upstream: N/A |
Branch: |
public/18868 |
Dependencies: |
-------------------------+-------------------------------------------------
Comment (by jdemeyer):
More about performance: note that your use of `MemoryAllocator` needs at
least 2 extra memory allocation calls compared to not using
`MemoryAllocator`: one to allocate the `MemoryAllocator` object and one to
allocate the `pointers` member. If you allocate several pointers, it's
worse because you again need more additional `realloc()` calls for
`pointers.`
To solve some of these problems, I propose the following: add a small
fixed array
{{{
cdef void* local_pointers[16]
}}}
in the `MemoryAllocator` class and initialize
{{{
self.max_size = 16
self.pointers = self.local_pointers
}}}
such that you avoid any allocations for `pointers` if you need to store at
most 16 pointers (which is the usual case I guess).
--
Ticket URL: <http://trac.sagemath.org/ticket/18868#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.