Commit f1815e7b authored by Stefan Behnel's avatar Stefan Behnel

Move a comment from the documentation into the example that it refers to, in...

Move a comment from the documentation into the example that it refers to, in order to avoid inconsistencies (e.g. line number references) and also to make it visible to those who only look at the file.
See #2353.
parent 692abf58
......@@ -13,6 +13,10 @@ def random_noise(int number=1):
for i in range(number):
my_array[i] = ran(0, 1)
# ... let's just assume we do some more heavy C calculations here to make up
# for the work that it takes to pack the C double values into Python float
# objects below, right after throwing away the existing objects above.
return [x for x in my_array[:number]]
finally:
# return the previously allocated memory to the system
......
......@@ -37,14 +37,6 @@ A very simple example of malloc usage is the following:
.. literalinclude:: ../../examples/tutorial/memory_allocation/malloc.pyx
:linenos:
.. note::
Here we take Python doubles (with ``ran(0, 1)``) and convert
them to C doubles when putting them in ``my_array``. After that,
we put them back into a Python list at line 19. So those C doubles
are converted again into Python doubles. This is highly inefficient,
and only for demo purposes.
Note that the C-API functions for allocating memory on the Python heap
are generally preferred over the low-level C functions above as the
memory they provide is actually accounted for in Python's internal
......
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