freenode/#lisp - IRC Chatlog
Search
9:50:36
pve
Hi! If I have a generic function "whitespacep" and compare it with another, "make-whitespace-predicate", which returns a function that recognizes whitespace, I get these results:
9:53:25
no-defun-allowed
whitespacep would perform method dispatch every time it is called, whereas make-whitespace-predicate only performs dispatch once. For such a small function, the runtime of method dispatch might be comparable to the runtime of your method.
9:55:13
no-defun-allowed
beach: Are you sure? I'm reading the opposite: test-1 invokes a generic function and takes 1.5 seconds, and test-2 does not and takes 0.6 seconds.
9:55:43
aeth
Hmm... Not noticably, though. (time (test-1)) (time (test-1)) has the second one faster, but not by much.
9:56:45
no-defun-allowed
No stress - it's Friday (evening after an electrical engineering exam here).
10:07:47
pve
is there a way to tell the compiler "I think I know what I'm doing, use only this whitespacep method and skip the dispatch"?
10:09:16
flip214
GET compares the INDICATOR via EQL, and that can't be changed, right? So if I did (SETF (GET 'sym '(text :de)) "foo") I can't use GET to retrieve but have to use SYMBOL-PLIST?!
10:10:21
flip214
or mark the function as INLINE and have a TYPECASE in there (with identical code, perhaps) - some past ELS used that to have the "right" optimized version for each usage