From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Re: [RFC] Some new vector procedures (vector-{memq, apply, to-string, ...}) Date: Sun, 21 Apr 2019 14:34:09 -0600 Message-ID: <87pnpf5c8u.fsf@gmail.com> References: <8736md90v0.fsf@gmail.com> <83lg05b1jk.fsf@gnu.org> <87lg047h9n.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="217106"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 21 22:34:50 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIJAo-000uNQ-5h for ged-emacs-devel@m.gmane.org; Sun, 21 Apr 2019 22:34:50 +0200 Original-Received: from localhost ([127.0.0.1]:56858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIJAn-00046k-01 for ged-emacs-devel@m.gmane.org; Sun, 21 Apr 2019 16:34:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIJAA-00046d-H0 for emacs-devel@gnu.org; Sun, 21 Apr 2019 16:34:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIJA9-0006BZ-Jc for emacs-devel@gnu.org; Sun, 21 Apr 2019 16:34:10 -0400 Original-Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:46966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIJA9-0006BP-BZ for emacs-devel@gnu.org; Sun, 21 Apr 2019 16:34:09 -0400 Original-Received: by mail-pl1-x632.google.com with SMTP id o7so2611776pll.13 for ; Sun, 21 Apr 2019 13:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=XVQDIzqAbDeL3lnKlS2SCdCfpWgm+s/ORMkwzDhoN3g=; b=qmZlt/m+2MG13docoMFLF8aNioyhnrZlb9aPxyK3f85/j8eRtIXNNFRlhy15+iZA3B k85xZmWjT2HVVQ1m7rD9NMyzMUQ3NF930tEGmTkDbmSz7J1A+tZDHIyuRYfASawZgtP1 /TK1jud8+dqQOajUjKV7nqxG3BkB3kyKA9Ztfe1548a4YzhgkaGMfCE1+fNyZpklEToI sxdqOBnIg+79zr7LzGkzQv0kWBAQaX0jzwByXoPhwD7VzE2qD2b5KK++FQCnqPPy2WxT h0/Dp4yGDKVo9cw2ERa6whuAHQ/AJRSCFLPWsYopVqPYUVVXj3/ZmlX8BeezyjBLRHFt 1W0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=XVQDIzqAbDeL3lnKlS2SCdCfpWgm+s/ORMkwzDhoN3g=; b=PllJBj9GD6W/epmCpkc7vsGKKZT6QwI4TPYsZRq0R9/xYpHT8aKnSb+DtpMPZBSY7f 39UNcKH4fwNXRqD2jW1LFSg9iUE927mUAWQaau845FwEIaL1QkCmFtORBxrsIrR39xc7 n0FwVyBAvqSw7eJXb+eAIO+OSfo3XZKR2sW7G+WFMO2eNo4Ah4tJCMevRSn/iDp/uQNm dVF4eJp3+ZvfscKR5QGn7C0plzeIXMZMMtFiYUS7Ddsigvse53Y1o5dGlt7HibfbIoC2 1XcQ64uCtbCpYT1h6oMlURu6Kx0h9YuzeBFnNW8NAPUizFumwPmaBKcK0DrXvkLpT8hF hKAA== X-Gm-Message-State: APjAAAXFr6UiS5H75WIRbLikxMdf77ACKcuDGpXYyT9Pnx4a0OfVlgRP xDSn9GVo5BrJRMRYeAFVU8wXcMuZ X-Google-Smtp-Source: APXvYqzbjWwaph2LgOHgspfRssQtNMioEsB0cu/8RHEdQU8fIu0ljxsA34/nmvi9e/4RUDI1Tgnokw== X-Received: by 2002:a17:902:714d:: with SMTP id u13mr7623369plm.104.1555878847928; Sun, 21 Apr 2019 13:34:07 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id c62sm21260158pfg.33.2019.04.21.13.34.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Apr 2019 13:34:07 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 21 Apr 2019 00:05:25 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::632 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235737 Archived-At: Stefan Monnier writes: >> I don't see any replacement for vector-apply, but I admit that the worth >> of that one might not be worth the change at this point. > > I'm not sure I like vector-apply, but I am interested in doing something > along these lines for cl-generic: the use of wrappers of the form > > (lambda (x &rest args) ... (apply f x args)) > > proves to be too costly in some cases (e.g. cl-print). But the main issue > seems to be the allocation of a new list for `args`, so `vector-apply` > doesn't really help here. I'm not sure how one would avoid the allocation lambda does without a new special form (or byte compiler optimization that checks that you only give args to apply), but perhaps I'm overlooking something. There could also be a &rest-vector, but that's likely going too far. >> For vector-memq, the Lisp implementations almost disallow it from being >> used over memq/lists. > > I your `vector-memq` significantly faster than `memq`? Not hugely; about 15-25% when vector-memq is made into a 2-byte bytecode (as in my other thread) for a 5 element collection, and about 50% on a 50-element collection. > My impression is that for small enough "sets", even if a bit faster, > `vector-memq` wouldn't bring much benefit, and for larger sets if > performance is an issue you'd likely prefer using a completely different > structure such as a hash-table. Right, I'm not under the impression that it would be a monumental difference (that's why I called it a stupid itch :). Still, I think there's a middle ground between lists and hash tables that vectors would fit into nicely enough.