Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Writing a simple RSS feed 'grabber' with XML::Parser.

by Juerd (Abbot)
on Oct 20, 2004 at 10:47 UTC ( [id://400812]=note: print w/replies, xml ) Need Help??


in reply to •Re^2: Writing a simple RSS feed 'grabber' with XML::Parser.
in thread Writing a simple RSS feed 'grabber' with XML::Parser.

perl -MBenchmark=cmpthese -e'cmpthese -1, { cute => sub { [0,1]->[rand + 2] }, list => sub { qw(0 1)[rand 2] } }'
Rate cute list cute 768000/s -- -74% list 2899719/s 278% --
Yes, the list slice is much faster. But for something that probably runs only once in every 5 minutes, isn't 768000 per second fast enough? Optimizing seems premature here. For things like this, I am against choosing a particular language or syntax for its speed.

I'm not saying that your reply is useless. It's important to know what code does and this information will certainly help some of the readers when they do have to optimize. But the code is written now and not much is gained by changing it, so I'd just let it be. Programmer time is still much more expensive than computer time.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
•Re^4: Writing a simple RSS feed 'grabber' with XML::Parser.
by merlyn (Sage) on Oct 20, 2004 at 11:04 UTC
    Please don't trot this out as an "optimization". What I'm saying is that this "cute syntax" is in fact gaining nothing, and only loses. So, if the only thing it's optimized for is "cuteness", it doesn't belong in the standard idiom list.

    So, at worst, I'm saving typing. Typically, I'm also saving execution speed. Why would you have a complaint about that?

    And what about the "programmer time" to figure out what the "cute" construct does? There's a real expense there. The literal slice is well documented. The cute block-arrow-block form shows up more like an obfuscation than a clarification, costing clarity, but for what reward? None, ever. Why unnecessarily obfuscate your code?

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found