Commit 80e154a
srikris
Make GLPickle more extensible.
Summary of changes
------------------
- Made GLPickle more extensible
- Used the extensibility mechanism to implement things for Model, SGraph,
SFrame, and SArray.
- Added some additional tests for the same.
Details
-------
Previously, GLPickle could not be extended without making changes directly to
it. Now, we added a mechanism to extend it by implementing 2 simple
methods:
1. __gl_pickle_save__: Save your object to a filename (not handle) given to you.
2. __gl_pickle_load__: Load your object from a filename (not handle) given to you.
As an example, here is a simple class that was extended to be pickled via
GLPickle.
class SampleClass(object):
def __init__(self, member):
self.member = member
def __gl_pickle_save__(self, filename):
with open(filename, 'w') as f:
f.write(self.member)
@staticmethod
def __gl_pickle_load__(filename):
with open(filename, 'r') as f:
member = f.read().split()
return SampleClass(member)1 parent a15453b commit 80e154a
7 files changed
Lines changed: 230 additions & 124 deletions
File tree
- oss_src/unity/python/sframe
- data_structures
- test
- toolkits
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
0 commit comments