tolf and detab

Walter Bright newshound2 at digitalmars.com
Sun Aug 8 14:27:41 PDT 2010


bearophile wrote:
> Walter Bright:
>> bearophile wrote:
>>> In the D code I have added an idup to make the comparison more fair,
>>> because in the Python code the "line" is a true newly allocated line, you
>>> can safely use it as dictionary key.
>> So it is with byLine, too. You've burdened D with double the amount of
>> allocations.
> 
> I think you are wrong two times:
> 
> 1) byLine() doesn't return a newly allocated line, you can see it with this
> small program:
> 
> import std.stdio: File, writeln;
> 
> void main(string[] args) { char[][] lines; auto file = File(args[1]); foreach
> (rawLine; file.byLine()) { writeln(rawLine.ptr); lines ~= rawLine; } 
> file.close(); }
> 
> 
> Its output shows that all "strings" (char[]) share the same pointer:
> 
> 14E5E00 14E5E00 14E5E00 14E5E00 14E5E00 14E5E00 14E5E00 ...

eh, you're right. the phobos documentation for byLine needs to be fixed.


> You can't do this in Python, but this is not what I want to test.

If you want to conclude that Python is better at processing files, you need to 
show it using each language doing it a way well suited to that language, rather 
than burdening one so it uses the same method as the less powerful one.


More information about the Digitalmars-d mailing list