Debian Codegraph @

testdata/python-dev/cur/1606884253.000004.mbox:2,

raw
1 From: "M.-A. Lemburg" <[email protected]>
2 To: [email protected]
3 Subject: Re: [Python-Dev] Pickling w/ low overhead
4 Date: Tue, 03 Aug 1999 11:11:11 +0200
5 Message-ID: <[email protected]>
6 In-Reply-To: <[email protected]>
7 MIME-Version: 1.0
8 Content-Type: multipart/mixed; boundary="===============1771830407250585468=="
9
10 --===============1771830407250585468==
11 Content-Type: text/plain; charset="utf-8"
12 Content-Transfer-Encoding: 7bit
13
14 David Ascher wrote:
15 >
16 > An issue which has dogged the NumPy project is that there is (to my
17 > knowledge) no way to pickle very large arrays without creating strings
18 > which contain all of the data. This can be a problem given that NumPy
19 > arrays tend to be very large -- often several megabytes, sometimes much
20 > bigger. This slows things down, sometimes a lot, depending on the
21 > platform. It seems that it should be possible to do something more
22 > efficient.
23 >
24 > Two alternatives come to mind:
25 >
26 > -- define a new pickling protocol which passes a file-like object to the
27 > instance and have the instance write itself to that file, being as
28 > efficient or inefficient as it cares to. This protocol is used only
29 > if the instance/type defines the appropriate slot. Alternatively,
30 > enrich the semantics of the getstate interaction, so that an object
31 > can return partial data and tell the pickling mechanism to come back
32 > for more.
33 >
34 > -- make pickling of objects which support the buffer interface use that
35 > inteface's notion of segments and use that 'chunk' size to do
36 > something more efficient if not necessarily most efficient. (oh, and
37 > make NumPy arrays support the buffer interface =). This is simple
38 > for NumPy arrays since we want to pickle "everything", but may not be
39 > what other buffer-supporting objects want.
40 >
41 > Thoughts? Alternatives?
42
43 Hmm, types can register their own pickling/unpickling functions
44 via copy_reg, so they can access the self.write method in pickle.py
45 to implement the write to file interface. Don't know how this
46 would be done for cPickle.c though.
47
48 For instances the situation is different since there is no
49 dispatching done on a per-class basis. I guess an optional argument
50 could help here.
51
52 Perhaps some lazy pickling wrapper would help fix this in general:
53 an object which calls back into the to-be-pickled object to
54 access the data rather than store the data in a huge string.
55
56 Yet another idea would be using memory mapped files instead
57 of strings as temporary storage (but this is probably hard to implement
58 right and not as portable).
59
60 Dunno... just some thoughts.
61
62 --
63 Marc-Andre Lemburg
64 ______________________________________________________________________
65 Y2000: 150 days left
66 Business: http://www.lemburg.com/
67 Python Pages: http://www.lemburg.com/python/
68
69
70
71 --===============1771830407250585468==--
72
73