From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0LesFkzDq17CSgAA0tVLHw (envelope-from ) for ; Fri, 01 May 2020 06:35:56 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WGuNCVXDq16RVgAAB5/wlQ (envelope-from ) for ; Fri, 01 May 2020 06:36:05 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5D4D19409EE for ; Fri, 1 May 2020 06:36:04 +0000 (UTC) Received: from localhost ([::1]:48790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUPHI-0004vP-FF for larch@yhetil.org; Fri, 01 May 2020 02:36:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38274) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUPGX-0004rv-BG for emacs-orgmode@gnu.org; Fri, 01 May 2020 02:35:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUPGV-0004WB-QH for emacs-orgmode@gnu.org; Fri, 01 May 2020 02:35:17 -0400 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:38058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUPGU-0004Kw-Oz for emacs-orgmode@gnu.org; Fri, 01 May 2020 02:35:15 -0400 Received: from [IPv6:2a01:e35:1398:10f0:4c74:3b1e:7840:71cd] (unknown [IPv6:2a01:e35:1398:10f0:4c74:3b1e:7840:71cd]) by smtp2-g21.free.fr (Postfix) with ESMTPS id 351E6200446 for ; Fri, 1 May 2020 08:35:12 +0200 (CEST) Subject: Re: [ANN] faster org-table-to-lisp To: emacs-orgmode@gnu.org References: <820681a6-4973-f016-6425-4afb9c9486a7@free.fr> <87wo5xcs3p.fsf@nicolasgoaziou.fr> <0166c38e-e1f2-9cbc-4cf8-1b287600368d@free.fr> <878sica9g2.fsf@nicolasgoaziou.fr> From: tbanelwebmin Message-ID: <9944ffa3-5e1f-56f2-c337-302b59d204f6@free.fr> Date: Fri, 1 May 2020 08:35:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <878sica9g2.fsf@nicolasgoaziou.fr> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Received-SPF: none client-ip=2a01:e0c:1:1599::11; envelope-from=tbanelwebmin@free.fr; helo=smtp2-g21.free.fr X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a01:e0c:1:1599::11 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: -1.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.01 / 13.00]; GENERIC_REPUTATION(0.00)[-0.49473780229711]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; FREEMAIL_FROM(0.00)[free.fr]; TO_DN_NONE(0.00)[]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.16), country: US(-0.00), ip: 2001:470:142::17(-0.49)]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[tbanelwebmin@free.fr,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; DMARC_NA(0.00)[free.fr]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: MSqXTb7InLcc Nicolas, how did you do that? Your version is 25% faster than mine, and the code is 33% shorter! Very elegant. Le 01/05/2020 à 00:35, Nicolas Goaziou a écrit : > tbanelwebmin writes: > >> I found a way to ensure full backward compatibility. I keep the same >> signature. When a table is given as a string parameter, it is inserted >> into a temporary buffer, which is then parsed. Overall, the resulting >> speed is quite satisfactory. > Awwww, you didn't like my ELEMENT suggestion. Sorry, I may not understood what you said: = Since you're changing the signature, I suggest to provide the table = element instead of ORG-AT-TABLE-P. AFAICT, `org-babel-read-element', = through `org-babel-read-table', would greatly benefit from this. Could you elaborate (if still relevant)? > >> I also made the function more tolerant to ill-formed tables: missing >> "|" or excess of spaces at the end of a row are now gracefully >> accepted. > Great! > >> (while (not (re-search-forward "\\=\\s-*\n" end t)) > (re-search-forward "\\=..." ...) -> (looking-at "..." ...) The side effect of `re-search-forward' was to advance point, while `looking-at' don't move. This does not matter anymore. > > Note that Org does not use \\s- but the simpler [ \t]. > > Also, the regexp assumes the table end with a newline character, which > may not be the case. > >> (unless (re-search-forward "\\=\\s-*\\([^|\n]*\\)\\(|?\\)" end t) >> (user-error "Malformed table at char %s" (point))) > This cannot happen. The regexp above matches anything, i.e., the empty > string. Right! I didn't noticed... > >> (goto-char (match-end 1)) >> (skip-chars-backward " \t" (match-beginning 1)) >> (push >> (buffer-substring-no-properties (match-beginning 1) (point)) >> row) >> (goto-char (match-end 2))) >> (push (nreverse row) table))) >> (nreverse table))))) > I applied your suggestion, with a few simplifications. Hopefully, it > squeezed a bit more the execution time. Let me know! Yes! 25% My two unit tests give correct results. > >> The new implementation can be more than 100 times faster. This enhances >> responsiveness of Babel or Gnuplot blocks handling thousands long >> tables. > Looks good. However, we didn't change the signature, so I didn't add > this to ORG-NEWS. It is in the commit message, tho. > > Thank you! > Nice team work, thank you too! Thierry Banel