Commit b3ee89c7 authored by root's avatar root

Merge branch 'master' of https://github.com/cython/cython

parents 758333e9 4bd204aa
......@@ -60,3 +60,5 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
iterator upper_bound(T&)
#const_iterator upper_bound(key_type&)
#value_compare value_comp()
void max_load_factor(float)
float max_load_factor()
......@@ -214,6 +214,8 @@ If ``__stdcall`` is used, the function is only considered compatible with
other ``__stdcall`` functions of the same signature.
.. _resolve-conflicts:
Resolving naming conflicts - C name specifications
--------------------------------------------------
......
......@@ -283,6 +283,9 @@ attribute access, you could just implement some properties::
def __set__(self, x0): self.thisptr.x0 = x0
...
If you prefer giving the same name to the wrapper as the C++ class, see the
section on :ref:`resolving naming conflicts <resolve-conflicts>`.
Advanced C++ features
======================
......@@ -477,6 +480,34 @@ The items in the containers are converted to a corresponding type
automatically, which includes recursively converting containers
inside of containers, e.g. a C++ vector of maps of strings.
Simplified wrapping with default constructor
--------------------------------------------
If your extension type instantiates a wrapped C++ class using the default
constructor (not passing any arguments), you may be able to simplify the
lifecycle handling by tying it directly to the lifetime of the Python wrapper
object. Instead of a pointer attribute, you can declare an instance::
cdef class VectorStack:
cdef vector[int] v
def push(self, x):
self.v.push_back(x)
def pop(self):
if self.v.empty():
raise IndexError()
x = self.v.back()
self.v.pop_back()
return x
Cython will automatically generate code that instantiates the C++ object
instance when the Python object is created and deletes it when the Python
object is garbage collected.
Exceptions
-----------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment