More efficient Python slicing

Call reserve for container types that support it to avoid repeated
memory reallocations for new slices or slices that grow in size.
This commit is contained in:
William S Fulton 2016-09-01 19:21:09 +01:00
commit 5abb3e8008
6 changed files with 45 additions and 0 deletions

View file

@ -16,6 +16,13 @@
}
}
template <class K, class T>
struct traits_reserve<std::unordered_multimap<K,T> > {
static void reserve(std::unordered_multimap<K,T> &seq, typename std::unordered_multimap<K,T>::size_type n) {
seq.reserve(n);
}
};
template <class K, class T>
struct traits_asptr<std::unordered_multimap<K,T> > {
typedef std::unordered_multimap<K,T> unordered_multimap_type;