Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Serialization
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Python=== The core general serialization mechanism is the <code>pickle</code> [[Python (programming language)#Libraries|standard library]] module, alluding to the database systems term ''pickling''<ref>{{cite journal|last1=Herlihy|first1=Maurice|last2=Liskov|first2=Barbara|author-link1=Maurice Herlihy|author-link2=Barbara Liskov|title=A Value Transmission Method for Abstract Data Types|journal=[[ACM Transactions on Programming Languages and Systems]]|date=October 1982|volume=4|issue=4|pages=527β551|doi=10.1145/69622.357182|url=http://cs.brown.edu/~mph/HerlihyL82/p527-herlihy.pdf|issn=0164-0925|oclc=67989840|citeseerx=10.1.1.87.5301|s2cid=8126961}}</ref><ref>{{cite book|last1=Birrell|first1=Andrew|last2=Jones|first2=Mike|last3=Wobber|first3=Ted|title=Proceedings of the eleventh ACM Symposium on Operating systems principles - SOSP '87 |chapter=A simple and efficient implementation of a small database |date=November 1987|volume=11|issue=5|pages=149β154|doi=10.1145/41457.37517|isbn=089791242X |issn=0163-5980|oclc=476062921|quote=Our implementation makes use of a mechanism called βpicklesβ, which will convert between any strongly typed data structure and a representation of that structure suitable for storing in permanent disk files. The operation Pickle.Write takes a pointer to a strongly typed data structure and delivers buffers of bits for writing to the disk. Conversely Pickle.Read reads buffers of bits from the disk and delivers a copy of the original data structure.(*) This conversion involves identifying the occurrences of addresses in the structure, and arranging that when the structure is read back from disk the addresses are replaced with addresses valid in the current execution environment. The pickle mechanism is entirely automatic: it is driven by the run-time typing structures that are present for our garbage collection mechanism. ... (*) Pickling is quite similar to the concept of marshalling in remote procedure calls. But in fact our pickling implementation works only by interpreting at run-time the structure of [[dynamically typed]] values, while our RPC implementation works only by generating code for the marshalling of statically typed values. Each facility would benefit from adding the mechanisms of the other, but that has not yet been done.|citeseerx=10.1.1.100.1457|s2cid=12908261}}</ref><ref>{{cite web|last1=van Rossum|first1=Guido|author-link1=Guido van Rossum|title=Flattening Python Objects|url=http://legacy.python.org/workshops/1994-11/FlattenPython.html|website=Python Programming Language β Legacy Website|publisher=[[Python Software Foundation]]|access-date=6 April 2017|location=[[Delaware]], United States|date=1 December 1994|quote=Origin of the name 'flattening': Because I want to leave the original 'marshal' module alone, and Jim complained that 'serialization' also means something totally different that's actually relevant in the context of [[Concurrent computing|concurrent]] access to persistent objects, I'll use the term 'flattening' from now on. ... (The Modula-3 system uses the term 'pickled' data for this concept. They have probably solved all problems already, and in a type-safe manner :-)}}</ref> to describe data serialization (''unpickling'' for ''deserializing''). Pickle uses a simple [[Stack (abstract data type)|stack]]-based [[virtual machine]] that records the instructions used to reconstruct the object. It is a cross-version [https://docs.python.org/library/pickle.html#pickle-protocol customisable] but unsafe (not secure against erroneous or malicious data) serialization format. Malformed or maliciously constructed data, may cause the deserializer to import arbitrary modules and instantiate any object.<ref name=autogenerated1>{{cite web|url=https://docs.python.org/2/library/pickle.html|title=11.1. pickle β Python object serialization β Python 2.7.14rc1 documentation|website=docs.python.org}}</ref><ref>{{cite web|url=https://docs.python.org/release/3.0.1/library/pickle.html#pickle-restrict|title=pickle β Python object serialization β Python v3.0.1 documentation|website=docs.python.org}}</ref> The standard library also includes modules serializing to standard data formats: <code>[https://docs.python.org/library/json.html json]</code> (with built-in support for basic scalar and collection types and able to support arbitrary types via [https://docs.python.org/library/json.html#encoders-and-decoders encoding and decoding hooks]). <code>[https://docs.python.org/library/plistlib.html plistlib]</code> (with support for both binary and XML [[property list]] formats). <code>[https://docs.python.org/library/xdrlib.html xdrlib]</code> (with support for the External Data Representation (XDR) standard as described in RFC 1014). Finally, it is recommended that an object's <code>[https://docs.python.org/reference/datamodel.html#object.__repr__ __repr__]</code> be evaluable in the right environment, making it a rough match for Common Lisp's <code>[http://www.lispworks.com/documentation/HyperSpec/Body/f_pr_obj.htm print-object]</code>. Not all object types can be pickled automatically, especially ones that hold [[operating system]] resources like [[file handle]]s, but users can register custom "reduction" and construction functions to support the pickling and unpickling of arbitrary types. Pickle was originally implemented as the pure Python <code>pickle</code> module, but, in versions of Python prior to 3.0, the <code>cPickle</code> module (also a built-in) offers improved performance (up to 1000 times faster<ref name=autogenerated1 />). The <code>cPickle</code> was adapted from the [[Unladen Swallow]] project. In Python 3, users should always import the standard version, which attempts to import the accelerated version and falls back to the pure Python version.<ref>{{cite web|url=https://docs.python.org/release/3.1.5/whatsnew/3.0.html|title=What's New In Python 3.0 β Python v3.1.5 documentation|website=docs.python.org}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Serialization
(section)
Add topic