unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Ken Raeburn <raeburn@raeburn.org>
Cc: Daniel Kraft <d@domob.eu>, guile-devel <guile-devel@gnu.org>
Subject: Re: Elisp performance
Date: Tue, 04 Aug 2009 21:28:52 +0200	[thread overview]
Message-ID: <m33a87bcp7.fsf@pobox.com> (raw)
In-Reply-To: <F27C2049-DD2C-499A-9308-DC08A619D69F@raeburn.org> (Ken Raeburn's message of "Tue, 4 Aug 2009 12:12:26 -0400")

On Tue 04 Aug 2009 18:12, Ken Raeburn <raeburn@raeburn.org> writes:

> On Aug 4, 2009, at 11:47, Andy Wingo wrote:
>>> In any case, because of dynamic scoping and the expected behaviour of
>>> flet to change possibly primitives during its extent, I think we
>>> can't
>>> do anything like that for Elisp (except providing guile-primitive for
>>> hand-optimizing such calls).
>>
>> Hmmmmmm. It seems that Emacs does inline, but it also reacts to flet.
>
> Which Emacs are you using here?  I'm using one of the pretest versions
> of GNU Emacs 23, and also tried 22.1, and both gave me different
> results from yours.

I'm using GNU Emacs 23.0.92.1 (i686-pc-linux-gnu, GTK+ Version 2.16.0)
of 2009-04-04

Something from git anyway.

>> ELISP> (defun add (x y) (+ x y))
>> add
>> ELISP> (compile-defun 'add)
>> nil
>
> Documentation says:
> ---
> compile-defun is an interactive compiled Lisp function in
> `bytecomp.el'.
>
> (compile-defun &optional arg)
>
> Compile and evaluate the current top-level form.
> Print the result in the echo area.
> With argument arg, insert value in current buffer after the form.
> ---
>
> So, the argument isn't a symbol to byte-compile the function definition
> of; it's just a flag.
> I used (byte-compile 'add).

Ahhhhh. Indeed now it prints 30 for me.

>> ELISP> (disassemble #'add)
>> byte code for add:
>>  args: (x y)
>> 0       varref    x
>> 1       varref    y
>> 2       plus
>> 3       return
>
> I got the same disassembly.

It appears "disassemble" actually compiled the function first, without
altering the defun.

>> How does this work? Ken do you know?
>
> My guess would be that the bytecode interpreter in your version is
> hardcoded to look up the function value of "+" and call it.  In Emacs
> 23 (and apparently 22.1), it calls the C function Fplus (which is the
> default function binding for the symbol "+"); it doesn't check to see
> if "+" has been redefined.

Yes I saw this, but was led astray via compile-defun ;)

Thanks, this shows that we can open-code primitives without worrying
about flet.

Cheers,

Andy
-- 
http://wingolog.org/




  reply	other threads:[~2009-08-04 19:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-29 12:50 Elisp performance Daniel Kraft
2009-07-30  3:23 ` Ken Raeburn
2009-07-31  5:15   ` Daniel Kraft
2009-08-04 15:51   ` Andy Wingo
2009-07-30 20:18 ` Neil Jerram
2009-07-30 23:54   ` Ken Raeburn
2009-07-31  6:09     ` Daniel Kraft
2009-08-04 10:26       ` Andy Wingo
2009-08-04 10:26     ` Andy Wingo
2009-07-31  6:02   ` Daniel Kraft
2009-07-31  9:59     ` Ken Raeburn
2009-07-31 15:14       ` Daniel Kraft
2009-08-04 11:14         ` Andy Wingo
2009-08-04 11:00     ` Andy Wingo
2009-08-08 22:15       ` Ludovic Courtès
2009-08-04 10:17   ` Andy Wingo
2009-08-04 10:54     ` Daniel Kraft
2009-08-04 15:58     ` Ken Raeburn
2009-08-04 15:47 ` Andy Wingo
2009-08-04 16:12   ` Ken Raeburn
2009-08-04 19:28     ` Andy Wingo [this message]
2009-08-04 16:17   ` Daniel Kraft
2009-08-04 19:25     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m33a87bcp7.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=d@domob.eu \
    --cc=guile-devel@gnu.org \
    --cc=raeburn@raeburn.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).