| 1 |
From: David Ascher <[email protected]> |
| 2 |
To: [email protected] |
| 3 |
Subject: [Python-Dev] Pickling w/ low overhead |
| 4 |
Date: Mon, 02 Aug 1999 16:01:26 -0700 |
| 5 |
Message-ID: <[email protected]> |
| 6 |
MIME-Version: 1.0 |
| 7 |
Content-Type: multipart/mixed; boundary="===============7807071734274799233==" |
| 8 |
|
| 9 |
--===============7807071734274799233== |
| 10 |
Content-Type: text/plain; charset="utf-8" |
| 11 |
Content-Transfer-Encoding: 7bit |
| 12 |
|
| 13 |
An issue which has dogged the NumPy project is that there is (to my |
| 14 |
knowledge) no way to pickle very large arrays without creating strings |
| 15 |
which contain all of the data. This can be a problem given that NumPy |
| 16 |
arrays tend to be very large -- often several megabytes, sometimes much |
| 17 |
bigger. This slows things down, sometimes a lot, depending on the |
| 18 |
platform. It seems that it should be possible to do something more |
| 19 |
efficient. |
| 20 |
|
| 21 |
Two alternatives come to mind: |
| 22 |
|
| 23 |
-- define a new pickling protocol which passes a file-like object to the |
| 24 |
instance and have the instance write itself to that file, being as |
| 25 |
efficient or inefficient as it cares to. This protocol is used only |
| 26 |
if the instance/type defines the appropriate slot. Alternatively, |
| 27 |
enrich the semantics of the getstate interaction, so that an object |
| 28 |
can return partial data and tell the pickling mechanism to come back |
| 29 |
for more. |
| 30 |
|
| 31 |
-- make pickling of objects which support the buffer interface use that |
| 32 |
inteface's notion of segments and use that 'chunk' size to do |
| 33 |
something more efficient if not necessarily most efficient. (oh, and |
| 34 |
make NumPy arrays support the buffer interface =). This is simple |
| 35 |
for NumPy arrays since we want to pickle "everything", but may not be |
| 36 |
what other buffer-supporting objects want. |
| 37 |
|
| 38 |
Thoughts? Alternatives? |
| 39 |
|
| 40 |
--david |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
--===============7807071734274799233==-- |
| 45 |
|
| 46 |
|