WIP: ERP5Type: deduplicate roles in pickles
This is "Proof of concept" following up discussion from !1560 (comment 153071)
security.declareProtected(Permissions.AccessContentsInformation,
'debug')
def debug(self):
""
from zodbpickle.pickle_2 import Unpickler
from ZODB.serialize import ObjectWriter
from ZODB.ExportImport import persistent_id
from io import BytesIO
from StringIO import StringIO
from zodbpickle.pickletools_2 import dis
from Acquisition import aq_base
ow = ObjectWriter(aq_base(self.getPortalObject()))
ow._p.dump(aq_base(self).__getstate__())
pkl = ow._file.getvalue()
disf = StringIO()
dis(pkl, disf)
msg = "pickle size: %s\n %s" % (len(pkl), disf.getvalue())
print(msg)
return msg
** Before **
pickle size: 756
0: } EMPTY_DICT
1: q BINPUT 1
3: ( MARK
4: U SHORT_BINSTRING 'default_reference'
23: q BINPUT 2
25: U SHORT_BINSTRING 'XXXX635'
34: q BINPUT 3
36: U SHORT_BINSTRING 'uid'
41: q BINPUT 4
43: L LONG 59161L
51: U SHORT_BINSTRING 'workflow_history'
69: q BINPUT 5
71: ( MARK
72: U SHORT_BINSTRING '\x00\x00\x00\x00\x00\x07|,'
82: q BINPUT 6
84: c GLOBAL 'Persistence.mapping PersistentMapping'
123: q BINPUT 7
125: t TUPLE (MARK at 71)
126: Q BINPERSID
127: U SHORT_BINSTRING '_Add_portal_content_Permission'
159: q BINPUT 8
161: ( MARK
162: U SHORT_BINSTRING 'Assignee'
172: q BINPUT 9
174: U SHORT_BINSTRING 'Assignor'
184: q BINPUT 10
186: U SHORT_BINSTRING 'Manager'
195: q BINPUT 11
197: U SHORT_BINSTRING 'Owner'
204: q BINPUT 12
206: t TUPLE (MARK at 161)
207: q BINPUT 13
209: U SHORT_BINSTRING '_owner'
217: q BINPUT 14
219: ( MARK
220: ] EMPTY_LIST
221: q BINPUT 15
223: U SHORT_BINSTRING 'acl_users'
234: q BINPUT 16
236: a APPEND
237: U SHORT_BINSTRING 'ERP5TypeTestCase'
255: q BINPUT 17
257: t TUPLE (MARK at 219)
258: q BINPUT 18
260: U SHORT_BINSTRING 'portal_type'
273: q BINPUT 19
275: U SHORT_BINSTRING 'Visa File'
286: q BINPUT 20
288: U SHORT_BINSTRING '_Modify_portal_content_Permission'
323: q BINPUT 21
325: ( MARK
326: U SHORT_BINSTRING 'Assignee'
336: q BINPUT 22
338: U SHORT_BINSTRING 'Assignor'
348: q BINPUT 23
350: U SHORT_BINSTRING 'Manager'
359: q BINPUT 24
361: U SHORT_BINSTRING 'Owner'
368: q BINPUT 25
370: t TUPLE (MARK at 325)
371: q BINPUT 26
373: U SHORT_BINSTRING '_Access_contents_information_Permission'
414: q BINPUT 27
416: ( MARK
417: U SHORT_BINSTRING 'Assignee'
427: q BINPUT 28
429: U SHORT_BINSTRING 'Assignor'
439: q BINPUT 29
441: U SHORT_BINSTRING 'Auditor'
450: q BINPUT 30
452: U SHORT_BINSTRING 'Manager'
461: q BINPUT 31
463: U SHORT_BINSTRING 'Owner'
470: q BINPUT 32
472: t TUPLE (MARK at 416)
473: q BINPUT 33
475: U SHORT_BINSTRING '__ac_local_roles__'
495: q BINPUT 34
497: } EMPTY_DICT
498: q BINPUT 35
500: ( MARK
501: h BINGET 17
503: ] EMPTY_LIST
504: q BINPUT 36
506: U SHORT_BINSTRING 'Owner'
513: q BINPUT 37
515: a APPEND
516: U SHORT_BINSTRING 'IS-ERPAD*_XXXFR*'
534: q BINPUT 38
536: ] EMPTY_LIST
537: q BINPUT 39
539: U SHORT_BINSTRING 'Assignor'
549: q BINPUT 40
551: a APPEND
552: U SHORT_BINSTRING 'DSO*'
558: q BINPUT 41
560: ] EMPTY_LIST
561: q BINPUT 42
563: U SHORT_BINSTRING 'Auditor'
572: q BINPUT 43
574: a APPEND
575: U SHORT_BINSTRING 'XXXFR*'
583: q BINPUT 44
585: ] EMPTY_LIST
586: q BINPUT 45
588: U SHORT_BINSTRING 'Auditor'
597: q BINPUT 46
599: a APPEND
600: U SHORT_BINSTRING 'AF*_XXXFR*'
612: q BINPUT 47
614: ] EMPTY_LIST
615: q BINPUT 48
617: U SHORT_BINSTRING 'Auditor'
626: q BINPUT 49
628: a APPEND
629: u SETITEMS (MARK at 500)
630: U SHORT_BINSTRING 'id'
634: q BINPUT 50
636: U SHORT_BINSTRING '20220624-57DF4'
652: q BINPUT 51
654: U SHORT_BINSTRING '_View_Permission'
672: q BINPUT 52
674: ( MARK
675: U SHORT_BINSTRING 'Assignee'
685: q BINPUT 53
687: U SHORT_BINSTRING 'Assignor'
697: q BINPUT 54
699: U SHORT_BINSTRING 'Auditor'
708: q BINPUT 55
710: U SHORT_BINSTRING 'Manager'
719: q BINPUT 56
721: U SHORT_BINSTRING 'Owner'
728: q BINPUT 57
730: t TUPLE (MARK at 674)
731: q BINPUT 58
733: U SHORT_BINSTRING 'quantity'
743: q BINPUT 59
745: G BINFLOAT 1.0
754: u SETITEMS (MARK at 3)
755: . STOP
** After **
pickle size: 596
0: } EMPTY_DICT
1: q BINPUT 1
3: ( MARK
4: U SHORT_BINSTRING 'default_reference'
23: q BINPUT 2
25: U SHORT_BINSTRING 'XXXX636'
34: q BINPUT 3
36: U SHORT_BINSTRING 'uid'
41: q BINPUT 4
43: L LONG 59700L
51: U SHORT_BINSTRING 'workflow_history'
69: q BINPUT 5
71: ( MARK
72: U SHORT_BINSTRING '\x00\x00\x00\x00\x00\x07|.'
82: q BINPUT 6
84: c GLOBAL 'Persistence.mapping PersistentMapping'
123: q BINPUT 7
125: t TUPLE (MARK at 71)
126: Q BINPERSID
127: U SHORT_BINSTRING '_Add_portal_content_Permission'
159: q BINPUT 8
161: ( MARK
162: U SHORT_BINSTRING 'Assignee'
172: q BINPUT 9
174: U SHORT_BINSTRING 'Assignor'
184: q BINPUT 10
186: U SHORT_BINSTRING 'Manager'
195: q BINPUT 11
197: U SHORT_BINSTRING 'Owner'
204: q BINPUT 12
206: t TUPLE (MARK at 161)
207: q BINPUT 13
209: U SHORT_BINSTRING '_owner'
217: q BINPUT 14
219: ( MARK
220: ] EMPTY_LIST
221: q BINPUT 15
223: U SHORT_BINSTRING 'acl_users'
234: q BINPUT 16
236: a APPEND
237: U SHORT_BINSTRING 'ERP5TypeTestCase'
255: q BINPUT 17
257: t TUPLE (MARK at 219)
258: q BINPUT 18
260: U SHORT_BINSTRING 'portal_type'
273: q BINPUT 19
275: U SHORT_BINSTRING 'Visa File'
286: q BINPUT 20
288: U SHORT_BINSTRING '_Modify_portal_content_Permission'
323: q BINPUT 21
325: ( MARK
326: h BINGET 9
328: h BINGET 10
330: h BINGET 11
332: h BINGET 12
334: t TUPLE (MARK at 325)
335: q BINPUT 22
337: U SHORT_BINSTRING '_Access_contents_information_Permission'
378: q BINPUT 23
380: ( MARK
381: h BINGET 9
383: h BINGET 10
385: U SHORT_BINSTRING 'Auditor'
394: q BINPUT 24
396: h BINGET 11
398: h BINGET 12
400: t TUPLE (MARK at 380)
401: q BINPUT 25
403: U SHORT_BINSTRING '__ac_local_roles__'
423: q BINPUT 26
425: } EMPTY_DICT
426: q BINPUT 27
428: ( MARK
429: h BINGET 17
431: ] EMPTY_LIST
432: q BINPUT 28
434: h BINGET 12
436: a APPEND
437: U SHORT_BINSTRING 'IS-ERPAD*_XXXFR*'
455: q BINPUT 29
457: ] EMPTY_LIST
458: q BINPUT 30
460: h BINGET 10
462: a APPEND
463: U SHORT_BINSTRING 'DSO*'
469: q BINPUT 31
471: ] EMPTY_LIST
472: q BINPUT 32
474: h BINGET 24
476: a APPEND
477: U SHORT_BINSTRING 'XXXFR*'
485: q BINPUT 33
487: ] EMPTY_LIST
488: q BINPUT 34
490: h BINGET 24
492: a APPEND
493: U SHORT_BINSTRING 'AF*_XXXFR*'
505: q BINPUT 35
507: ] EMPTY_LIST
508: q BINPUT 36
510: h BINGET 24
512: a APPEND
513: u SETITEMS (MARK at 428)
514: U SHORT_BINSTRING 'id'
518: q BINPUT 37
520: U SHORT_BINSTRING '20220624-1203CE'
537: q BINPUT 38
539: U SHORT_BINSTRING '_View_Permission'
557: q BINPUT 39
559: ( MARK
560: h BINGET 9
562: h BINGET 10
564: h BINGET 24
566: h BINGET 11
568: h BINGET 12
570: t TUPLE (MARK at 559)
571: q BINPUT 40
573: U SHORT_BINSTRING 'quantity'
583: q BINPUT 41
585: G BINFLOAT 1.0
594: u SETITEMS (MARK at 3)
595: . STOP
highest protocol among opcodes = 1