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: Sat, 20 Apr 2019 10:50:28 -0600 Message-ID: <87lg047h9n.fsf@gmail.com> References: <8736md90v0.fsf@gmail.com> <83lg05b1jk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="82728"; 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: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 20 19:05:40 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 1hHtQq-000LJS-8r for ged-emacs-devel@m.gmane.org; Sat, 20 Apr 2019 19:05:40 +0200 Original-Received: from localhost ([127.0.0.1]:43498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHtQo-0006BJ-OB for ged-emacs-devel@m.gmane.org; Sat, 20 Apr 2019 13:05:38 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHtPY-0005Jl-Fl for emacs-devel@gnu.org; Sat, 20 Apr 2019 13:04:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHtCB-0003hY-53 for emacs-devel@gnu.org; Sat, 20 Apr 2019 12:50:32 -0400 Original-Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:34352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHtCA-0003Xt-Vf; Sat, 20 Apr 2019 12:50:31 -0400 Original-Received: by mail-pg1-x535.google.com with SMTP id v12so3987093pgq.1; Sat, 20 Apr 2019 09:50:29 -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=VpTVOY01L7LQtJYI7BezoI8pH2UmbIbPBSkTFhY4EBA=; b=INW+8CjiTAp3soicx8CdEIVWd2esXaAqlhabM86Kdw+crXg5zddHpp4gIA/xW5ZDfd w+VxqBnYDg+mPqK11GlvefToNknd8ZPa9mr7zPVBxsrVe9XjNgr8OkFJOUS3Oir9lj+E wHntK7hGsf874EBnJgGaVh3+sG+I4LrySyGilDoWEye+pJDzFeKAqBGdulhHNBVEvAZ5 bygt8Wrveyka+kKGpwqGaUCNVV/6moEz2tBwn3iS7u2uZEJJmX6kdZSePQ2GJ1Vt1l1a 1pAKQffMNJhg9IDakYmR2CUG2WFoCZKRslnH8ZbCVOZ/v+R/IYSAuQPygvlRzXt9N8/V PeIw== 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=VpTVOY01L7LQtJYI7BezoI8pH2UmbIbPBSkTFhY4EBA=; b=jqZqfbYP1YTMEJtlbEN9TqF++Ap1agoRkCxdMJnOXOck4iCEFTw1l0Fd7HokrKlaBj Rs45gD+C+YVRAvFCsFqe/LH3asUAvX0u/Rke4UgzcTzMP+1N0r+AGnqbth4CcwcnMsrt +4sbdIj6iMW2VsEC02Xyj9LXdJwd+2DMqqkx200rzmFdVDi9kQQWWSH2jvxa831RGLCx QG2IL8J7cLFr/X44PSGglRD6VwuCCbe4V6qnjnFSKz8Hn//UAqS3szhFvaVB88/Oyknj zhnosJAaSP7yQ1PjYCu4IfXz3CwlZtQVmZm0j/smOnnFfCE+wmm1kKHg95IHzNcbAq4O AtOA== X-Gm-Message-State: APjAAAUgRXOwUrk7T7Ql2cojvP6s2qlcC01TPm0p2yAwlNU7bwDNgG7C Rk0eihTNrXdlfgGg9lZNA3Q5wacI X-Google-Smtp-Source: APXvYqwwZnBZ6RSe7UuTD/pbyqps8r71tSWQ4T7rK9UQvSGNfZigl8Mq7y5b+r/H9GNoQER34b1Qrw== X-Received: by 2002:a65:6546:: with SMTP id a6mr9953613pgw.5.1555779027900; Sat, 20 Apr 2019 09:50:27 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id x5sm11560895pfi.91.2019.04.20.09.50.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Apr 2019 09:50:26 -0700 (PDT) In-Reply-To: <83lg05b1jk.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 20 Apr 2019 10:04:15 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::535 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:235702 Archived-At: Eli Zaretskii writes: >> From: Alex Gramiak >> Date: Fri, 19 Apr 2019 14:49:39 -0600 >> >> Here are a few procedures that should make using vectors in Elisp a bit >> nicer. They are in C since all the Elisp versions I've tried were too >> slow for such simple procedures. > > Doesn't seq.el already provide this functionality? Some, but not all. I don't see a vector-partition equivalent (seq-partition is different), or a vector-index equivalent (seq-find/cl-find return the element instead of the index, and is ~10x slower). 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. Though I just remembered that (concat vec) does the same as vector-to-string; if vector-to-string is added, then I suppose it should be a Lisp wrapper around concat just like string-to-vector is around vconcat. > As for speed, did you have any application where the speed of the Lisp > implementation was inadequate? For vector-memq, the Lisp implementations almost disallow it from being used over memq/lists. The equivalent in seq.el, seq-position, is ~100x slower for smaller vectors and ~200x for larger (500 elements) vectors. A cl-loop implementation is just slightly better than seq-position. The main two I care about here are vector-memq/vector-member. The other ones were just ones I thought up while I was at it.