From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14289 invoked from network); 27 Nov 2021 20:23:04 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Nov 2021 20:23:04 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1638044584; b=B4c26QLD/RJ/Hlv5OVrpD6t5wqhci8vWKzlrA0iI7KqnzKoqDUpY1KFMv3K4WTDS8n/iSA9JAQ eTBUv+/VBoBLX2xEk0xsAT+uzFUqZjRsSvvfbh6N04blYmi/x1qUtWkvwCNBIgtQLylJEx9W5R Q3DxQvvKTLs/2bHLcHdU5Lf0luPaG3F4rgz8oprJxKO0gzOh/XOAz61VtSIffh8pwiQTk5xY79 UEvXbu7QWwDBuyWU2znQJ/MTrIQRUkRQIXG/O6syiCJUmSz03RBmkh6o7olpcd1wv9cMha5Pao DdOHFDI0P+dxCVQnSx2VbHeGhgPBidCcs9vSfCwziIj1dA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f176.google.com) smtp.remote-ip=209.85.219.176; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1638044584; bh=A3B8uuMRq31tuvU/Lz0SctiqS9M8EYNhsuV1cLf6itI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=F4+gsVVK3VzNGW32sk8XhCX5ci4u3zPgN5IEErdWhxVqqAM36SamujUl3uTs6QT6x3zE3Sn+BA GXFk7DVMsftiKKLsaoHF9qLuMAHKdTDV0cND6wGANKzVBX/af30M2vCQUjYAcWvKwsDSHcsSzH /FxOSHXZUCtU5BECAy/SWeCGCuL3V0lgwFp7kgIqZlpLtNLiHUGAQwYkXNAJGLMPoivOG9aLGb +MTI/ZQCo8Qyhr2+XPQEhHkEumrdtP8qmqc1PxM87zeM9nSBRk830oxLqftgYB5XPSIV3cK1h0 X9av9bky0lC2W/m8pokzVHJFVMc8LmMMgvV9snWAfpkivQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=csIrvj6B47my9yomwztFve3xRNOWC6Oj1Cv1bDtEGTE=; b=pdnANkgkjiClwhcdR3r/qsdf1G Njvqx4nXRA2oPt64/PzqJ0UYVj44sxQYsbtfaduWOdFbIjzNdcFIg2wCTiwjKpCFwbQ0FjccPKUBg nM2bxOUerfBYAAN2hw+uh/GkjfYyX7l1azW+WhM9u4T7tQbr7bQEyNyrcNRi3+7dKlIj6RBlZR0X2 wj11qZu6i3p+qIvu312Jb3fAiExJhX7k7OxzGpD/5cA6+iSIYhf97E91WgTwT0GqAx3Lzx5maSxDt 7qLI0r0smBR3qhL5iGjduxxXI2ZrdBbbH/1W2ltceg83LGBWpmfAPlFM2VFlvEAghflTDhYGNAUFI R73FNQHA==; Received: from authenticated user by zero.zsh.org with local id 1mr4Dw-00003h-3D; Sat, 27 Nov 2021 20:23:04 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f176.google.com) smtp.remote-ip=209.85.219.176; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f176.google.com ([209.85.219.176]:35366) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mr4DE-000PL7-La; Sat, 27 Nov 2021 20:22:21 +0000 Received: by mail-yb1-f176.google.com with SMTP id f186so29702863ybg.2 for ; Sat, 27 Nov 2021 12:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=csIrvj6B47my9yomwztFve3xRNOWC6Oj1Cv1bDtEGTE=; b=4dapjnjNtOZo/iP32/gk3llixxIP9TVYu5UzNeBQFfqLPX/sTMy5CE2798Jt681haj 3NiZ5TyavugQR+MWxrUyJymwrIZc7xk0gDfGWuxju0cD1h2h7sls7xO3rsM2o1jIKw26 dGInsTVo+EDzWY05s/+gbss+0LoiTb1IqELjKSMpb39fQ5n09VZYdgGAYF0Z7Nw86PEy 5J9a5oAigaad5feJ/TuzoKLXKNvq7kgI/6Q3ajufhCFV77/ybjC+VgBrqTKY1K14nDIz xZrJXS1o8AfwQw103/Kbiwj91gSOMQhN3ABUeSVPQ/Bhiaos3Smb4lbP43YRUfELbv6K UFew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=csIrvj6B47my9yomwztFve3xRNOWC6Oj1Cv1bDtEGTE=; b=isq5rwry/vQVs6wOTG+jUY8l3pxk59tC4ozjkUwhToL3DFKOqTfOmPqOi/5eHmVCJa 9VPomlI+NfyyRXpmxgGGMCD5FrepWEOdCDfmZd3Tpd1fV8jUnZyYoCar7mhBJ8HuNTwJ 9Dk9B2HJ4WdFmR85QA7AQzowNoXAuFewMa+HdYs7W5wEBDkIFkeb4OpjahHiFUE7FXGh 1teLB6sVfu+zkDojO/41jIm6R/6uA8gaSbAqr4/KUIqEP2RZvm5ZBs63uBIsMAwVMkhn TvMH+2gJ2XbPWAQJxdH8sgKj8s5bXxUAp70tA5e3lj9kvox7mYRn3CbTovCeDFbEuYwL Sxhg== X-Gm-Message-State: AOAM531PwqYqju2o1QPMqYYMpUuL0dOWcLyzDdcjwBOt15R7L+O83xjj pgTObnbMqHyULlp1HtggVYDr/NOZytiX8Y7lxJ1OcA== X-Google-Smtp-Source: ABdhPJwhW4B122JGDCTWzxZbBgrw3f0wptQ6UxsyaSrpBV6PekOU9XQ2mngVXZLcXM25CT6j1B6N2yupgVAW/Hv+OQk= X-Received: by 2002:a25:9988:: with SMTP id p8mr24051293ybo.32.1638044539718; Sat, 27 Nov 2021 12:22:19 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Sat, 27 Nov 2021 12:22:08 -0800 Message-ID: Subject: Re: Shell startup, aliases vs. functions vs. autoloadable functions, and zcompile benefits To: Zach Riggle Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27375 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Sat, Nov 27, 2021 at 12:33 AM Roman Perepelitsa wrote: > > On Sat, Nov 27, 2021 at 9:11 AM Zach Riggle wrote: > > > > alias foo='foo --flag1 --flag2' > > foo() { command foo --flag1 --flag2 "$@" } > > autoloadable module containing (2) > > In theory the first and the last should have the same performance and > the middle should be slower because it has to parse the body. In > practice you won't find any difference: zsh parser is very fast. This is true for shell startup time; at runtime there's a small penalty for the middle one (allocating the function context) and on the very first execution there's an additional load-time cost for the third one. Again you're unlikely to notice unless your $fpath entries are numerous and deep. The tradeoff is that the third one occupies less memory than either of the other two (though about the same as the alias) which is significant if there are a lot of seldom-used functions. Otherwise, everything Roman said.