Dan Sugalski wrote:

> At 1:04 AM +0900 4/4/03, Daniel Berger wrote:
> 
>> Dan Sugalski wrote:
>>
>>>
>> <snip>
>>
>>>  Be aware that perl cheats unmercifully at IO, to the extent of
>>>  peeking beneath the C IO library hood and acting directly on the
>>>  underlying buffer structure. While somewhat evil (okay, it's very
>>>  evil) it does cut out at least one level of function calls for IO,
>>>  and speeds things up some.
>>>  --
>>>                                           Dan
>>
>>
>> This must be the vaunted Perl IO layer that I've seen mentioned from
>> time to time.
> 
> 
> Nope. That's more a Tcl/SysV style streams thing, and is relatively new. 
> This is old code, and has been in perl for years.
> 
>>  Any reason Ruby couldn't "cheat" as well?  Anything Ruby
>> can borrow here?
> 
> 
> Sure, license willing. (And I'm pretty sure it is, but I'd double-check 
> with Larry and Matz first) The code's in sv.c, in the Perl_sv_gets 
> function, though there's a fair amount of gook and macro expansion you 
> may have to do to actually make sense of it. The code's in there, 
> though. Evil, definitely evil, but it is there.
Ok.  New results:

Both files contain 1,572,682 lines.
BIG line file avg line length   = 46
SMALL line file avg line length = 11

All tests without writing to screen (only elapsed time written at end of 
run):

py22 BIG       = 5
py22 SMALL     = 3

ruby168 BIG    = 319
ruby168 SMALL  = 95

ruby18p2 BIG   = 12
ruby18p2 SMALL = 12

Java BIG       = 7
Java SMALL     = 3

FYI --

Greg Brondo