[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sbcl-help
Subject:    Re: [Sbcl-help] fast slot access
From:       Nikodemus Siivola <nikodemus () random-state ! net>
Date:       2014-12-08 13:06:13
Message-ID: CADow0CqE60+QOy1ZJi=7PVhHMxeFjeTCK+CgYpfiMaxC2qauXw () mail ! gmail ! com
[Download RAW message or body]

Inlining a generic function like FOO-VAR is not going to help in SBCL
as it currently stands. That may change some day, but let's speak of
what is instead of what might be.

The exact performance of FOO-VAR is going to depend on other methods
on it. I don't remember the details, but unless I'm badly mistaken as
long as all methods on it are accessors the performance will be
exactly the same as using SLOT-VALUE with a constant slot name. If
there are non-accessor methods on it (including before/after/around on
accessors), it will be a bit slower, but *probably* not terribly
slower.

However, if you want *really* fast slot accesses you should use
DEFSTRUCT instead of DEFCLASS, and FOO-BAR style non-generic
accessors. Clearly more performant than CLOS.

(There are also MOP tricks you can play, but that's a more complex topic.)


On 8 December 2014 at 12:29, FAU <fau@riseup.net> wrote:
> (defclass foo ()
>   ((var :initarg :var :accessor foo-var)))
> (declaim (inline foo-var))
>
> (defparameter *foo* (make-instance 'foo :var 42))
>
> ;;; Which is to be expected faster?
> (setf (foo-var *foo*) 1)
> ;;; vs
> (setf (slot-value *foo* 'var) 2)
>
> Thanks
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
> _______________________________________________
> Sbcl-help mailing list
> Sbcl-help@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sbcl-help

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Sbcl-help mailing list
Sbcl-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic