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
ee0f7bf6
Commit
ee0f7bf6
authored
May 11, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pickling tests.
parent
efc33c7c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
tests/run/reduce_pickle.pyx
tests/run/reduce_pickle.pyx
+49
-0
No files found.
tests/run/reduce_pickle.pyx
0 → 100644
View file @
ee0f7bf6
cdef
class
A
:
"""
>>> a = A(3); a
A(3)
>>> import cPickle
>>> cPickle.loads(cPickle.dumps(a))
A(3)
>>> import pickle
>>> pickle.loads(pickle.dumps(a))
A(3)
"""
cdef
int
value
def
__init__
(
self
,
value
):
self
.
value
=
value
def
__repr__
(
self
):
return
"A(%s)"
%
self
.
value
def
__reduce__
(
self
):
return
A
,
(
self
.
value
,)
cdef
class
B
:
"""
>>> b = B(x=37, y=389); b
B(x=37, y=389)
>>> import cPickle
>>> cPickle.loads(cPickle.dumps(b))
B(x=37, y=389)
>>> import pickle
>>> pickle.loads(pickle.dumps(b))
B(x=37, y=389)
"""
cdef
int
x
,
y
def
__init__
(
self
,
x
=
0
,
y
=
0
):
self
.
x
=
x
self
.
y
=
y
def
__repr__
(
self
):
return
"B(x=%s, y=%s)"
%
(
self
.
x
,
self
.
y
)
def
__reduce__
(
self
):
return
makeB
,
({
'x'
:
self
.
x
,
'y'
:
self
.
y
},)
def
makeB
(
kwds
):
return
B
(
**
kwds
)
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