Article View: comp.arch
Article #2Re: Optimization by programmers
From: Stefan Monnier
Date: Tue, 06 Oct 2026 18:55
Date: Tue, 06 Oct 2026 18:55
15 lines
2376 bytes
2376 bytes
> What I found most interesting is how it sorts or why it sorts. It
> took me a while to understand what makes it work. It is difficult,
> for example, to write invariants for this code that can be used to
> establish the conclusion that sorting actually takes place.
Indeed, mostly because the first iteration (i=0) is completely different
from the other ones: the swaps that take place happen only when
i > j or i == 0
So only the first iteration of the outer loop really works on the whole
array. The subsequent ones do nothing once j > i.
=== Stefan
Technical Details
Message-ID:
<jwvfqyioea5.fsf-monnier+comp.arch@gnu.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<1177fdi$26ea4$1@dont-email.me> <6aa5876f.783937@news.eternal-september.org> <2026Sep12.201446@mips.complang.tuwien.ac.at> <6aa6172e.15711625@news.eternal-september.org> <2026Sep13.162747@mips.complang.tuwien.ac.at> <118h4cj$fi2a$1@dont-email.me> <118ltsc$26ss6$1@dont-email.me> <2026Sep19.175649@mips.complang.tuwien.ac.at> <118odha$31okp$1@dont-email.me> <86a4pct2oj.fsf@linuxsc.com> <119q3q8$36790$2@paganini.bofh.team> <8633unnhed.fsf@linuxsc.com> <11a19rf$3u6ge$1@paganini.bofh.team> <86a4orm9yh.fsf@linuxsc.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Stefan Monnier <monnier@iro.umontreal.ca> Newsgroups: comp.arch Subject: Re: Optimization by programmers Date: Tue, 06 Oct 2026 14:55:05 -0400 Organization: A noiseless patient Spider Lines: 15 Message-ID: <jwvfqyioea5.fsf-monnier+comp.arch@gnu.org> References: <1177fdi$26ea4$1@dont-email.me> <6aa5876f.783937@news.eternal-september.org> <2026Sep12.201446@mips.complang.tuwien.ac.at> <6aa6172e.15711625@news.eternal-september.org> <2026Sep13.162747@mips.complang.tuwien.ac.at> <118h4cj$fi2a$1@dont-email.me> <118ltsc$26ss6$1@dont-email.me> <2026Sep19.175649@mips.complang.tuwien.ac.at> <118odha$31okp$1@dont-email.me> <86a4pct2oj.fsf@linuxsc.com> <119q3q8$36790$2@paganini.bofh.team> <8633unnhed.fsf@linuxsc.com> <11a19rf$3u6ge$1@paganini.bofh.team> <86a4orm9yh.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 07 Oct 2026 05:39:31 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2723775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19F14rUPAtuNrjROQMyLR0Zfd6ec6x5GQg="; posting-host="9d67604ddfe46c2ab2376c3119577664" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:RJyeCID/EM5sskw2fP+6aoMMo5o= sha1:sfvriu0BxzGIY8Vs4biYkyfwRgA= sha256:TfMObz1zG6YTUIwhZr7jEpJhOqRg0d7sM5coTxeavz0= sha1:QoVD64ELbgDBr37p0JaO188H9T4= sha256:1eKKCzNQRq5OdIq1HmjgliIrDfmVix5wHga9Kacyj0k= In-Reply-To: <86a4orm9yh.fsf@linuxsc.com> (message from Tim Rentsch <tr.17687@z991.linuxsc.com> on Tue, 06 Oct 2026 02:53:26 -0700)