The copyreg module defines functions which are used by pickling specific objects while pickling or copying. This module provides configuration information about object constructors(may be factory functions or class instances) which are not classes.
This function is used for declaring object as a valid constructor. An object is not considered as a valid constructor if it is not callable. This function raises TypeError if the object is not callable.
copyreg.pickle(type, function, constructor=None)
This is used to declare function as a “reduction” function for objects of type type. function should return either a string or a tuple containing two or three elements.
The constructor parameter is optional. It is a callable object which can be used to reconstruct the object when called with the tuple of arguments returned by function at pickling time. TypeError is raised if object is a class or constructor is not callable.
pickling a C instance... pickling a C instance... b'\x80\x03c__main__\nC\nq\x00K\x01\x85q\x01Rq\x02.'
This article is contributed by Aditi Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- pickle — Python object serialization
- Major Kernel Functions in Support Vector Machine (SVM)
- SymPy | Permutation.support() in Python
- Introduction to Support Vector Machines (SVM)
- Classifying data using Support Vector Machines(SVMs) in Python
- Mathematical Functions in Python | Set 1 (Numeric Functions)
- Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions)
- Mathematical Functions in Python | Set 3 (Trigonometric and Angular Functions)
- Mathematical Functions in Python | Set 4 (Special Functions and Constants)
- Operator Functions in Python | Set 2
- Time Functions in Python | Set-2 (Date Manipulations)
- Partial Functions in Python
- Time Functions in Python | Set 1 (time(), ctime(), sleep()...)
- Calendar Functions in Python | Set 1( calendar(), month(), isleap()...)
- Calendar Functions in Python | Set 2(monthrange(), prcal(), weekday()...)
- Complex Numbers in Python | Set 2 (Important Functions and Constants)
- Complex Numbers in Python | Set 3 (Trigonometric and Hyperbolic Functions)
- Array in Python | Set 2 (Important Functions)
- Statistical Functions in Python | Set 1 (Averages and Measure of Central Location)
- Statistical Functions in Python | Set 2 ( Measure of Spread)