From: Javier
Subject: Some speed questions
Date: 
Message-ID: <1155672625.213843.72020@i42g2000cwa.googlegroups.com>
I'm actually using SBCL, my question is:

which is faster?

* Creating objects with defclass and generic methods.
* Creating my own simple object system using lists and macros.
* Creating my own simple object system using GET and macros (for
example (get object 'slot) and (setf (get object 'slot))).

Javier.

From: Ari Johnson
Subject: Re: Some speed questions
Date: 
Message-ID: <87ac65ohia.fsf@bender.theari.com>
"Javier" <·······@gmail.com> writes:

> I'm actually using SBCL, my question is:
> 
> which is faster?
> 
> * Creating objects with defclass and generic methods.

The implementation of CLOS included with SBCL includes an optimizing
compiler macro for slot-value.  Even without that, the worst-case is
probably still faster than the below.  Note that generic methods don't
really play a part in your question, since you do not suggest how you
would accomplish similar functionality with your "own simple object
system."

> * Creating my own simple object system using lists and macros.

This depends a great deal on what you store in the lists and what the
macros do.

> * Creating my own simple object system using GET and macros (for
> example (get object 'slot) and (setf (get object 'slot))).

(get symbol property-name) is implemented as a loop across the
symbol-plist (property list) of the symbol.  This is almost certainly
slower than the hand-crafted-for-efficiency CLOS implementation of
slot-value (which I believe is implemented in terms of constant-time
array accesses).

All that being the case, CLOS is faster in terms of your overall time,
since it is already there and ready for you to use.  Even if you can
come up with a faster way to do it by leaving out features of CLOS you
don't need, you still have to invest the time in creating
infrastructure.
From: John Thingstad
Subject: Re: Some speed questions
Date: 
Message-ID: <op.tece98mgpqzri1@pandora.upc.no>
On Tue, 15 Aug 2006 22:45:17 +0200, Ari Johnson <·········@gmail.com>  
wrote:

which I believe is implemented in terms of constant-time array accesses.

For the record it is.
http://www.lisp.org/mop/index.html

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: funkyj
Subject: Re: Some speed questions
Date: 
Message-ID: <1155754399.775860.233060@m79g2000cwm.googlegroups.com>
Javier wrote:
> I'm actually using SBCL, my question is:
>
> which is faster?
>
> * Creating objects with defclass and generic methods.
> * Creating my own simple object system using lists and macros.
> * Creating my own simple object system using GET and macros (for
> example (get object 'slot) and (setf (get object 'slot))).

Create a skeleton implementation of your home grown object systems and
then benchmark them against CLOS.

If it isn't worth your time to create a few simple benchmarks then you
are probably better off using CLOS since this will save you developer
time.
From: Pascal Costanza
Subject: Re: Some speed questions
Date: 
Message-ID: <4kh9prFc9eh7U1@individual.net>
Javier wrote:
> I'm actually using SBCL, my question is:
> 
> which is faster?
> 
> * Creating objects with defclass and generic methods.
> * Creating my own simple object system using lists and macros.
> * Creating my own simple object system using GET and macros (for
> example (get object 'slot) and (setf (get object 'slot))).

It depends on what you want to program in it. If your problem can be 
nicely expressed in terms of CLOS, then it will probably be very hard to 
beat its performance. If a different kind of object system would be 
better suited for your problem, and you have to build lots of 
workarounds in CLOS to make it work, then it might be more suitable to 
implement a homegrown solution. However, I expect this to be a rare case.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/