mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 d9dfaa9487
			
		
	
	
		d9dfaa9487
		
	
	
	
	
		
			
			or dumping pickles with a 2.x-compatible protocol, in order to make data sharing and migration easier. This behaviour can be disabled using the new `fix_imports` optional argument.
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			627 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			627 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import pickle
 | |
| import pickletools
 | |
| from test import support
 | |
| from test.pickletester import AbstractPickleTests
 | |
| from test.pickletester import AbstractPickleModuleTests
 | |
| 
 | |
| class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
 | |
| 
 | |
|     def dumps(self, arg, proto=None):
 | |
|         return pickletools.optimize(pickle.dumps(arg, proto))
 | |
| 
 | |
|     def loads(self, buf):
 | |
|         return pickle.loads(buf)
 | |
| 
 | |
|     # Test relies on precise output of dumps()
 | |
|     test_pickle_to_2x = None
 | |
| 
 | |
| 
 | |
| def test_main():
 | |
|     support.run_unittest(OptimizedPickleTests)
 | |
|     support.run_doctest(pickletools)
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     test_main()
 |