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
9e55199c
Commit
9e55199c
authored
Jun 18, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved an example from string.rst into the examples directory for testing.
parent
5c04c1a8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
docs/examples/tutorial/string/return_memview.pyx
docs/examples/tutorial/string/return_memview.pyx
+7
-0
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+2
-8
No files found.
docs/examples/tutorial/string/return_memview.pyx
0 → 100644
View file @
9e55199c
def
process_byte_data
(
unsigned
char
[:]
data
,
bint
return_all
):
# ... process the data
if
return_all
:
return
bytes
(
data
)
else
:
# example for returning a slice
return
bytes
(
data
[
5
:
35
])
docs/src/tutorial/strings.rst
View file @
9e55199c
...
@@ -228,15 +228,9 @@ when only a small slice is returned. Since memoryviews do not copy the
...
@@ -228,15 +228,9 @@ when only a small slice is returned. Since memoryviews do not copy the
data, they would otherwise keep the entire original buffer alive. The
data, they would otherwise keep the entire original buffer alive. The
general idea here is to be liberal with input by accepting any kind of
general idea here is to be liberal with input by accepting any kind of
byte buffer, but strict with output by returning a simple, well adapted
byte buffer, but strict with output by returning a simple, well adapted
object. This can simply be done as follows:
:
object. This can simply be done as follows:
def process_byte_data(unsigned char[:] data):
.. literalinclude:: ../../examples/tutorial/string/return_memview.pyx
# ... process the data
if return_all:
return bytes(data)
else:
# example for returning a slice
return bytes(data[5:35])
If the byte input is actually encoded text, and the further processing
If the byte input is actually encoded text, and the further processing
should happen at the Unicode level, then the right thing to do is to
should happen at the Unicode level, then the right thing to do is to
...
...
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