2018-07-03 | Paul Boddie | file changeset files shortlog | Introduced a class (unpackable) and method (__get_single_item_unchecked__) to support sequence unpacking without index checking overhead, since the translator emits a test for the length of each sequence and controls the actual index values used. | tuple-optimisations |
paul@2 | 1 | class C: |
paul@2 | 2 | x = 3 |
paul@2 | 3 | |
paul@2 | 4 | def f(): |
paul@2 | 5 | x = g.x |
paul@266 | 6 | print x # 3 |
paul@2 | 7 | y = g |
paul@266 | 8 | print y # __main__.C |
paul@2 | 9 | return y.x |
paul@2 | 10 | |
paul@266 | 11 | def i(): |
paul@266 | 12 | x = h.x |
paul@266 | 13 | y = h |
paul@266 | 14 | return y |
paul@266 | 15 | |
paul@2 | 16 | g = C |
paul@2 | 17 | result = f() |
paul@266 | 18 | print result # 3 |
paul@266 | 19 | |
paul@266 | 20 | h = C |
paul@266 | 21 | print i() # __main__.C |
paul@266 | 22 | print i().x # 3 |
paul@266 | 23 | |
paul@266 | 24 | h = C() |
paul@266 | 25 | print i() # <__main__.C instance> |
paul@266 | 26 | print i().x # 3 |