On Fri, Jan 9, 2009 at 3:55 AM, Zbigniew Lukasiak <zzb...@gmail.com> wrote:
> Hi,
>
> Is it feasible to build a Moose object with an Inline C method?
>
> We have here some Inline C based parsers for network packets (mostly
> analogue to Net::Packet).  They build a hash with the parsed values -
> so using standard Perl OO I would just bless that hash and be done,
> but I guess in Moose that would not be that simple.

Well it *might* work but there are no gurantees when you violate the
MOP. You could build hashes and pass them to a class's constructor:

MyPacket->new(%packet_data)

Obviously this would slow the process down some.

> For some background - the throughput of our communication streams
> (SMS) require that it is done in that low level (this was a decision
> done before I came here but I have done some rudimentary tests and, to
> my surprise, the Inline C based vesions are indeed many times faster
> than the Net::Packet versions that use pack/unpack).  Now my task is
> to write some OO wrappers to our libraries.  Of course I don't know if
> the OO overhead will not spoil the advantage that we get from parsing
> in C - I'll have to verify that, I think this will depend much on the
> usage.

There are several options in this realm, a look at how some of the XS
works in Class::MOP and a talk with some of the more XS savvy Moose
people in #moose might help out too.

-Chris

Reply via email to