tolf and detab

bearophile bearophileHUGS at
Sun Aug 8 18:51:42 PDT 2010


>Where does xio derive its performance advantage from?<

I'd like to give you a good answer, but I can't. dlibs1 (that you can found online still) has a Python Licence, so to create xio.xfile() I have just translated to D1 the C code of the CPython implementation code of the file object I have already linked here.

I think it minimizes heap allocations, the performance is tuned for a line length found to be the "average one" for normal files. So I presume if your text file has very short lines (like 5 chars each) or very long ones (like 1000 chars each) it becomes less efficient.

So it's probably a matter of good usage of the C I/O functions and probably a more efficient management by the GC.

Phobos is Boost Licence, but I don't think Python devs can get mad if you take a look at how Python reads lines lazily :-) Someone has tried to implement a Python-style associative array in a similar way.


More information about the Digitalmars-d mailing list