?

Log in

No account? Create an account
Why I love perl my $string = pack "w*", %$edges; my… - Artur Bergman [entries|archive|friends|userinfo]
Artur Bergman

[ website | O'Reilly Radar ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Oct. 11th, 2006|10:11 pm]
Artur Bergman
Why I love perl

 
   my $string = pack "w*", %$edges;
    my $status = $self->db->put("edge_$id}", $string);

....


   my $status = $self->db->get("edge_$id", $edges);
   return { unpack "w*", $edges };

LinkReply

Comments:
[User Picture]From: frobisher
2006-10-12 05:36 am (UTC)
It's really disturbing that the reason you love perl has anything to do with pack()... :-)
(Reply) (Thread)
[User Picture]From: crucially
2006-10-12 05:38 am (UTC)
but it is soooo fast
(Reply) (Parent) (Thread)
[User Picture]From: obra
2006-10-12 05:54 am (UTC)
There's something really wrong about the fact that upon reading that, my first thought was:

. o O { So's whitaker's mom }

I don't even work there.
(Reply) (Parent) (Thread)
[User Picture]From: obra
2006-10-12 06:03 am (UTC)
Could be worse. He could be using Formats.
(Reply) (Parent) (Thread)
[User Picture]From: frobisher
2006-10-12 06:05 am (UTC)
Or pseudohashes, I suppose *shudder*
(Reply) (Parent) (Thread)
[User Picture]From: crucially
2006-10-12 06:29 am (UTC)
hush, that is completely different


I actually used formats for the first time evah a couple of months ago :)
(Reply) (Parent) (Thread)
[User Picture]From: zudini
2006-10-13 03:55 am (UTC)
Is that } in the db->put line a typo, or is there some sneaky reason for it?

Also, what is your opinion on python's pickle()?
(Reply) (Thread)
[User Picture]From: crucially
2006-10-13 05:57 am (UTC)
That was just a type, actually a bug I discovered just after posting :)

I haven't really used pickling, I have used storable in perl and this is about 20% faster than using storable to store the hash. That said the big win is really the fact that they get BER compressed and since all I am storing is integers... :)

(Reply) (Parent) (Thread)