in reply to Optimizing binary file parser (pack/unpack)

Depending on whether you actually need to unpack each record or not, you can maybe hardcode the offsets to reject rows before actually unpacking them. index can quickly look at a position in a string without needing pack or unpack.

Depending on how you unpack things, it might be quicker to build one large unpack template instead of unpacking items in a loop.

  • Comment on Re: Optimizing binary file parser (pack/unpack)

Replies are listed 'Best First'.
Re^2: Optimizing binary file parser (pack/unpack)
by pwagyi (Monk) on Oct 03, 2017 at 08:16 UTC
    I've to unpack all fields of records. Yes I'm already grouping one large template as much as possible. But there are optional fields in record so that had to be handled as well.