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
Kirill Smelkov
cython
Commits
038812a7
Commit
038812a7
authored
Jun 22, 2018
by
scoder
Committed by
GitHub
Jun 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2385 from gabrieldemarmiesse/test_string_10
Adding tests for "Unicode and passing strings" part 10
parents
b1667e9e
f72b9bd0
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 @
038812a7
# 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 @
038812a7
...
...
@@ -345,18 +345,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