From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25147 invoked by alias); 4 Feb 2017 15:47:43 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22435 Received: (qmail 26360 invoked from network); 4 Feb 2017 15:47:43 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-5.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.69):SA:0(-1.3/5.0):. Processed in 0.810033 secs); 04 Feb 2017 15:47:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.69 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=CMjXJkfD c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=MWUjAzoEKyAA:10 a=gDuU0EbtgF_GVQrTnmgA:9 a=y2GmgV1uMJzkj0Qc:21 a=NvTTKyu_fgnuPEK3:21 a=CjuIK1q_8ugA:10 Date: Sat, 4 Feb 2017 15:47:36 +0000 From: Peter Stephenson To: Zsh Users Subject: Re: efficiency Message-ID: <20170204154736.5a51b119@ntlworld.com> In-Reply-To: References: <20170204150513.4087c834@ntlworld.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 04 Feb 2017 07:39:28 -0800 Ray Andrews wrote: > I think what I was really asking is if, in an interpreted language the > time spent calculating is offset by the time spent parsing. That is, in > C you'd be more efficient doing the calculation once (besides what you > say above), but maybe in zsh the important thing is to reduce the number > of lines or the number of variables or something like that. Or, on the > contrary, maybe the simpler form is doubly better since the lines are > shorter and thus save parsing time as well as calculation time. Typically, in a real script, you'd find the difference in time made so little difference having it look neat was preferable. You'd only start looking at optimisations if this was in an inner loop and had to run many times; or was in a function that lots of users had to run very many times a day; or involved a significantly larger amount of data if done one way rather than the other; or something like that. I'm sure this has come up before, but if you're in a position where a saving of this kind is important, there's a good chance you shouldn't really be using a shell at all. pws