.readline() - PERL AGAIN FASTER !

Harald Schneider h_schneider at marketmix.com
Tue Nov 21 06:37:03 EST 2000


I knew this would come .... :-))

Your code ran with 1.11 sec (PYTHON was 1.52)

Thanks a lot!
My presonal result of this thread is that both languages are flexible and
fast enough
top fit my needs. At first PYTHON looked dramatically slow in this special
case. But
the more ideomatic form did manage the problem. This thread gave me enough
information
to add Python to my toolbox for furhter projects. Thanks to all of you!

All the best,
Harald

> Just another Perl/Python hacker,

Yes. Together they revamp the web!


"Mats Kindahl" <matkin at iar.se> schrieb im Newsbeitrag
news:umhf51y3p3.fsf at iar.se...
> "Harald Schneider" <h_schneider at marketmix.com> writes:
>
> > FANTASTIC !
> > 1.52 sec. with your code (PERL was: 3.705)
> >
> > You gave me the reason to dig more into Python :) Thanks a lot!
>
> [snip]
>
> In fairness to Perl, you should use a more "Perl-ionic"
> ("Perl-iodic"?) approach as well---i.e., using regular expressions
> instead of splitting the string.
>
> Try the following version of your code.
>
>     #!/usr/bin/perl
>
>     use Time::HiRes;
>
>     $_db = 'test.dat';
>     print "Running...\n";
>
>     $secStart = Time::HiRes::time;
>
>     open(DB, "<$_db") or die "Can't open $_db";
>     while ($dbline = <DB>) {
> if ($dbline =~ /^TEST/) {
>     print("FOUND: $dbline\n");
>     last;
> }
>     }
>     print("DONE!\n");
>     close(DB);
>     printf("Elapsed time: %f sec.\n", (Time::HiRes::time - $secStart));
>
>     exit(0);
>
> It was significantly faster on my test input.
>
> Just another Perl/Python hacker,
>
> --
> Mats Kindahl, IAR Systems, Sweden
>
> Any opinions expressed are my own, not my company's.





More information about the Python-list mailing list