Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

slowpickle.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. '''
  3. The zodbpickle.pickle module exposes the standard behavior of
  4. the pickle module.
  5. This is backward compatible, but has the effect that by default,
  6. on Python3 you get the fast implementation, while on Python2
  7. you get the slow implementation.
  8. This module is a version that always exposes the slow implementation
  9. of pickling and avoids the need to explicitly touch internals.
  10. '''
  11. '''
  12. Note: We are intentionally using "import *" in this context.
  13. The imported modules define an __all__ variable, which contains
  14. all the names that it wants to export.
  15. So this is a rare case where 'import *' is exactly the right thing to do.
  16. '''
  17. if sys.version_info[0] >= 3:
  18. import zodbpickle.pickle_3 as p
  19. # undo the replacement with fast versions
  20. p.Pickler, p.Unpickler = p._Pickler, p._Pickler
  21. p.dump, p.dumps, p.load, p.loads = p._dump, p._dumps, p._load, p._loads
  22. del p
  23. # pick up all names that the module defines
  24. from .pickle_3 import *
  25. # do not share the globals with a fast version
  26. del sys.modules['zodbpickle.pickle_3']
  27. else:
  28. # pick up all names that the module defines
  29. from .pickle_2 import *
  30. del sys