Next: , Previous: , Up: Numbers   [Contents][Index]


5.11.2 Non-Descriptor Representations

From the discussion above, we can see that the standard descriptor representation has many problems, the worst being number consing. Common Lisp compilers try to avoid these descriptor efficiency problems by using non-descriptor representations. A compiler that uses non-descriptor representations can compile this function so that it does no number consing:

(defun multby (vec n)
  (declare (type (simple-array single-float (*)) vec)
           (single-float n))
  (dotimes (i (length vec))
    (setf (aref vec i)
          (* n (aref vec i)))))

If a descriptor representation were used, each iteration of the loop might cons two floats and do three times as many memory references.

As its negative definition suggests, the range of possible non-descriptor representations is large. The performance improvement from non-descriptor representation depends upon both the number of types that have non-descriptor representations and the number of contexts in which the compiler is forced to use a descriptor representation.

Many Common Lisp compilers support non-descriptor representations for float types such as single-float and double-float (section float-efficiency.) Python adds support for full word integers (see word-integers), characters (see characters) and system-area pointers (unconstrained pointers, see system-area-pointers.) Many Common Lisp compilers support non-descriptor representations for variables (section ND-variables) and array elements (section specialized-array-types.) Python adds support for non-descriptor arguments and return values in local call (see number-local-call) and structure slots (see raw-slots).


Next: Variables, Previous: Descriptors, Up: Numbers   [Contents][Index]