Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

perl pack/unpack compiled version

by pwagyi (Monk)
on Mar 27, 2018 at 08:24 UTC ( [id://1211828]=perlquestion: print w/replies, xml ) Need Help??

pwagyi has asked for the wisdom of the Perl Monks concerning the following question:

Greeting monks!

I am just wondering if there is any module on CPAN that is counterpart to built-in pack/unpack. That will offer compiled template (for fixed template), so that for performance critical bits, compiled pack/unpack could be used. I believe clojure/python has something similar.

#hypothetical module use Binary::Parser; $compiled_template = Binary::Parser->new( template => 'nCC C/a'); my @result = $compiled_template->unpack($binary_data); # would be nice to have, like regex ? (0 or one) at the end # it will match C C/a # C C/a B8 # C C/a B8 f ... $optional_template = Binary::Parser->new( template => 'C C/a (B8 ff c +c)?');

Replies are listed 'Best First'.
Re: perl pack/unpack compiled version
by Anonymous Monk on Mar 27, 2018 at 11:09 UTC
    Pack/unpack is fairly optimized. Usually faster than dropping into some xs stuff. See convert::binary::c

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1211828]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-23 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found