Skip to content

Releases: hubo1016/namedstruct

v1.3.1

23 Oct 02:31
5039026
Compare
Choose a tag to compare

This release re-implemented the prepack stage. Before this release, the executing orders for prepack functions are:

  1. prepack functions from embedded structures in the base structure
  2. prepack functions of base
  3. prepack functions from embedded structures in the extended (children) structure
  4. prepack functions of extended (children) structure
  5. prepack functions of named fields (when packing)

After this release, the prepack stage executes on every parts and fields in the structure, strictly following this order:

  1. prepack stages of named fields and embedded structures from base and extension (children) are executed recursively, in the definition order (or the serialization order)
  2. prepack functions of base are executed
  3. prepack functions of extensions are executed, from base to children

This gives chances to prepack functions in fields and embedded structures to change the size of some fields without corrupting the calculation of structure size.

For example, s2 defined in the following code

s1 = nstruct(
            (nstruct(prepack=p1), 'field1'),        # field
            (nstruct(
                (nstruct(prepack=p2), 'field2'),    # embedded field
                prepack=p3),),                             # embedded structure
            (nstruct(
                (nstruct(prepack=p4), 'field3'),    # field of field
                prepack=p5), 'field4'),                 # field
            name='s1',
            prepack=p6)

s2 = nstruct(
            (nstruct(prepack=p7), 'field5'),        # field
            (nstruct(
                (nstruct(prepack=p8), 'field6'),    # embedded field
                prepack=p9),),                             # embedded structure
            (nstruct(
                (nstruct(prepack=p10), 'field7'),   # field of field
                prepack=p11), 'field8'),                # field
            name='s2',
            base=s1,
            criteria=lambda x: True,
            prepack=p12)

The old executing order for prepack functions are: p3, p6, p9, p12, p1, p2, p5, p4, p7, p8, p11, p10

The new executing order of prepack functions are: p1, p2, p3, p4, p5, p7, p8, p9, p10, p11, p6, p12

You can use an empty embedded structure with prepack functions to ensure it executes in the desirable order.

v1.3.0

07 Aug 02:12
Compare
Choose a tag to compare

This release introduces new interfaces and modified memoryview usage to increase performance.

v1.2.0

22 Aug 07:36
Compare
Choose a tag to compare

dump() returns OrderedDict when possible