xxxInPlace or xxxCopy?

bearophile bearophileHUGS at lycos.com
Wed Jan 19 18:56:39 PST 2011


so:

> Isn't simplicity and understandability favors the in-place style on these  
> type of algorithms?

Nope, functional-style code is what you are looking for :-)


> As Jesse Phillips said, it is same as sort.

You have to think of the normal sort as a performance hack, something that is good because copying data wastes a lot of time, if the array is large or if you have to sort an many small arrays. Normally in Python you prefer sorted(), that returns a sorted copy, unless performance is important. I'd like something like sorted() in D too.

In a program there is code that's performance-critical, and other code that's not changing the total runtime much. Often the second kind of code is a good part of the whole program. In this part you want very short, readable, safer code, even functional-style :-)

Bye,
bearophile


More information about the Digitalmars-d mailing list