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 sEiQJtSHql6WBQAA0tVLHw (envelope-from ) for ; Thu, 30 Apr 2020 08:09: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 0KfxBN2Hql7RAwAAB5/wlQ (envelope-from ) for ; Thu, 30 Apr 2020 08:10: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 2C1F49429E3 for ; Thu, 30 Apr 2020 08:10:04 +0000 (UTC) Received: from localhost ([::1]:53570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU4Gh-00072r-SE for larch@yhetil.org; Thu, 30 Apr 2020 04:10:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39374) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jU4GJ-00072d-9T for emacs-orgmode@gnu.org; Thu, 30 Apr 2020 04:09:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jU4GI-00006a-4i for emacs-orgmode@gnu.org; Thu, 30 Apr 2020 04:09:38 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:38897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jU4GH-000060-5o for emacs-orgmode@gnu.org; Thu, 30 Apr 2020 04:09:37 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 0014F240018; Thu, 30 Apr 2020 08:09:31 +0000 (UTC) From: Nicolas Goaziou To: tbanelwebmin Subject: Re: [ANN] faster org-table-to-lisp References: <820681a6-4973-f016-6425-4afb9c9486a7@free.fr> Mail-Followup-To: tbanelwebmin , emacs-orgmode@gnu.org Date: Thu, 30 Apr 2020 10:09:30 +0200 In-Reply-To: <820681a6-4973-f016-6425-4afb9c9486a7@free.fr> (tbanelwebmin@free.fr's message of "Thu, 30 Apr 2020 08:34:32 +0200") Message-ID: <87wo5xcs3p.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=217.70.183.193; envelope-from=mail@nicolasgoaziou.fr; helo=relay1-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/30 04:09:32 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Received-From: 217.70.183.193 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: , Cc: emacs-orgmode@gnu.org 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]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49417936370429]; HAS_XOIP(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.17), country: US(-0.00), ip: 2001:470:142::17(-0.49)]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; MAILLIST(-0.20)[mailman]; FREEMAIL_TO(0.00)[free.fr]; 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)[mail@nicolasgoaziou.fr,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[nicolasgoaziou.fr]; HAS_LIST_UNSUB(-0.01)[]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: CrHs8BCW7Iob Hello, tbanelwebmin writes: > Here is an alternative, faster version of org-table-to-lisp. It can be > more than 100 times faster. Great! Thank you! > #+BEGIN_SRC elisp > (defun org-table-to-lisp-faster (&optional org-table-at-p-done) > =C2=A0 "Convert the table at point to a Lisp structure. > The structure will be a list.=C2=A0 Each item is either the symbol `hline' > for a horizontal separator line, or a list of field values as strings. > The table is taken from the buffer at point. > When the optional ORG-TABLE-AT-P-DONE parameter is not nil, it is > assumed that (org-at-table-p) was already called." 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. Or, to be backward compatible, I suggest &optional TEXT TABLE > =C2=A0 (or org-table-at-p-done (org-at-table-p) (user-error "No table at = point")) > =C2=A0 (save-excursion > =C2=A0=C2=A0=C2=A0 (goto-char (org-table-begin)) > =C2=A0=C2=A0=C2=A0 (let ((end (org-table-end)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (row) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (table)) Nitpick: (row nil) (table nil) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (while (< (point) end) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq row nil) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (search-forward "|" end) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (looking-at "-") > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (progn > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (search-forward "\n" end) (forward-line) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (push 'hline table)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (while (not (searc= h-forward-regexp "\\=3D\n" end t)) (unless (eolp) ...) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unles= s (search-forward-regexp "\\=3D\\s-*\\([^|]*\\)" end t) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (user-error "Malformed table at char %s" (point))) A row may not be properly ended. It doesn't warrant an error. Could you make it more tolerant? Also `search-forward-regexp' -> `re-search-forward', i.e., use the original. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let (= (b (match-beginning 1)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (e (match-end=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 1))) Nitpick: spurious spaces. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (and (search-backward-regexp "[^ \t]" b t) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (forward-char 1)) (skip-chars-backward " \t") > It is faster because it operates directly on the buffer with > (search-forward-regexp). Whereas the standard function splits a string > extracted from the buffer. You are right. I guess the initial implementation didn't have these monster tables in mind. > This function is a drop-in replacement for the standard one. It can > benefit to Babel and Gnuplot. > > Would it make sense to upgrade Org Mode code base? Certainly. Could you add an entry in ORG-NEWS, in "Miscellaneous"? Regards, --=20 Nicolas Goaziou