Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
f72b9bd0
Commit
f72b9bd0
authored
Jun 21, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug in the cpp example and moved it to the examples directory.
parent
04780910
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
docs/examples/tutorial/string/cpp_string.pyx
docs/examples/tutorial/string/cpp_string.pyx
+12
-0
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+2
-11
No files found.
docs/examples/tutorial/string/cpp_string.pyx
0 → 100644
View file @
f72b9bd0
# distutils: language = c++
from
libcpp.string
cimport
string
def
get_bytes
():
py_bytes_object
=
b'hello world'
cdef
string
s
=
py_bytes_object
s
.
append
(
'abc'
)
py_bytes_object
=
s
return
py_bytes_object
docs/src/tutorial/strings.rst
View file @
f72b9bd0
...
...
@@ -365,18 +365,9 @@ C++ strings
When wrapping a C++ library, strings will usually come in the form of
the :c:type:`std::string` class. As with C strings, Python byte strings
automatically coerce from and to C++ strings:
:
automatically coerce from and to C++ strings:
# distutils: language = c++
from libcpp.string cimport string
cdef string s = py_bytes_object
try:
s.append('abc')
py_bytes_object = s
finally:
del s
.. literalinclude:: ../../examples/tutorial/string/cpp_string.pyx
The memory management situation is different than in C because the
creation of a C++ string makes an independent copy of the string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment