Choisissez la catégorie, puis la rubrique :

13.2 cPickle -- A faster pickle

13.2 cPickle -- A faster pickle

The cPickle module supports serialization and de-serialization of Python objects, providing an interface and functionality nearly identical to the pickle module. There are several differences, the most important being performance and subclassability.

First, cPickle can be up to 1000 times faster than pickle because the former is implemented in C. Second, in the cPickle module the callables Pickler() and Unpickler() are functions, not classes. This means that you cannot use them to derive custom pickling and unpickling subclasses. Most applications have no need for this functionality and should benefit from the greatly improved performance of the cPickle module.

The pickle data stream produced by pickle and cPickle are identical, so it is possible to use pickle and cPickle interchangeably with existing pickles.13.10

There are additional minor differences in API between cPickle and pickle, however for most applications, they are interchangeable. More documentation is provided in the pickle module documentation, which includes a list of the documented differences.


... pickles.13.10
Since the pickle data format is actually a tiny stack-oriented programming language, and some freedom is taken in the encodings of certain objects, it is possible that the two modules produce different data streams for the same input objects. However it is guaranteed that they will always be able to read each other's data streams.
See About this document... for information on suggesting changes.
Python est sacré langage de programmation de l'année 2018 selon l'index TIOBE
Java, JavaScript et C++ ont été les langages les plus demandés en entreprise ces 9 derniers mois
Microsoft dévoile en open source Pyright, un vérificateur de type statique
Apprendre 23 principes pour écrire du code lisible, un tutoriel d'Artur Smiarowski
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web