From shapiro at cse.Buffalo.EDU Thu Jan 8 15:56:48 2009 From: shapiro at cse.Buffalo.EDU (Stuart C. Shapiro) Date: Thu, 08 Jan 2009 10:56:48 -0500 Subject: [clpython-devel] Calling Python functions from Lisp [Re Franz thread: spr35431] Message-ID: <49662240.1080703@cse.buffalo.edu> I think that I have successfully installed CLPython. What I want to do is to call Python functions, defined in programs written by others, from Allegro Common Lisp. So here is a test Python program called test.py: ----------------------------- # A Python file to use to test clpython def test(): print "I am a Python function." return "I am done." print("The Python test file has been run.") ----------------------------- I loaded clpython, and did (note: this wasn't the first time I imported test, so test.fasl and test.pyc already existed.): ----------------------------- cl-user(3): (clpython:run "import test; test.test()") Warning: *import-recompiled-files* = # Warning: /net/projects/shapiro/clpython/test.fasl not in # ; Fast loading /net/projects/shapiro/clpython/test.fasl The Python test file has been run. Warning: *import-recompiled-files* = # Warning: /net/projects/shapiro/clpython/test.fasl not in # I am a Python function. "I am done." ----------------------------- First question: Why the Warning messages? How can I get rid of them? Notice that I can make use of the values returned by the Python function: ----------------------------- cl-user(4): (setf x (clpython:run "import test; test.test()")) Warning: *import-recompiled-files* = # Warning: /net/projects/shapiro/clpython/test.fasl not in # ; Fast loading /net/projects/shapiro/clpython/test.fasl The Python test file has been run. Warning: *import-recompiled-files* = # Warning: /net/projects/shapiro/clpython/test.fasl not in # I am a Python function. "I am done." cl-user(5): x "I am done." ----------------------------- What I'd really like to do now is to call test.test() as much as possible as though it were a Common Lisp function. One possible way is: ----------------------------- cl-user(6): (clpython:run "test.test()") Error: NameError: Variable `test' is unbound. [condition type: NameError] Restart actions (select using :continue): 0: Enter a Lisp value to use for `test'. 1: Return to Top Level (an "abort" restart). 2: Abort entirely from this (lisp) process. ----------------------------- But, the name of the function does not seem to survive from one call of clpython:run to another. Final question: How can I do this? stu -- Stuart C. Shapiro Professor, Department of Computer Science and Engineering University at Buffalo, The State University of New York 201 Bell Hall, Box 602000, Buffalo, NY 14260-2000, U.S.A. PHONE: 716-645-3180x125 FAX: 716-645-3464 shapiro at cse.buffalo.edu http://www.cse.buffalo.edu/~shapiro/ From metawilm at gmail.com Fri Jan 9 10:12:24 2009 From: metawilm at gmail.com (Willem Broekema) Date: Fri, 9 Jan 2009 11:12:24 +0100 Subject: [clpython-devel] Calling Python functions from Lisp [Re Franz thread: spr35431] In-Reply-To: <49662240.1080703@cse.buffalo.edu> References: <49662240.1080703@cse.buffalo.edu> Message-ID: Hello Stuart, welcome to the list. On Thu, Jan 8, 2009 at 4:56 PM, Stuart C. Shapiro wrote: > cl-user(3): (clpython:run "import test; test.test()") > Warning: *import-recompiled-files* = # > Warning: /net/projects/shapiro/clpython/test.fasl not in > # > ; Fast loading /net/projects/shapiro/clpython/test.fasl > [...] > First question: Why the Warning messages? How can I get rid of them? Those were debug messages accidentally left in. They have been removed now. Sorry about that. > Notice that I can make use of the values returned by the Python function: > ----------------------------- > cl-user(4): (setf x (clpython:run "import test; test.test()")) > Warning: *import-recompiled-files* = # > Warning: /net/projects/shapiro/clpython/test.fasl not in > # > ; Fast loading /net/projects/shapiro/clpython/test.fasl > The Python test file has been run. > Warning: *import-recompiled-files* = # > Warning: /net/projects/shapiro/clpython/test.fasl not in > # > I am a Python function. > "I am done." > > cl-user(5): x > "I am done." Yes, the last value of the Python expression is returned. > What I'd really like to do now is to call test.test() as much as > possible as though it were a Common Lisp function. One possible way is: > ----------------------------- > cl-user(6): (clpython:run "test.test()") > Error: NameError: Variable `test' is unbound. > [condition type: NameError] > > Restart actions (select using :continue): > 0: Enter a Lisp value to use for `test'. > 1: Return to Top Level (an "abort" restart). > 2: Abort entirely from this (lisp) process. > ----------------------------- > But, the name of the function does not seem to survive from one call of > clpython:run to another. > > Final question: How can I do this? There is not an elegent way for that yet (I'm working on it), but the following works: cl-user(6): :pa clpython clpython(7): (setf *habitat* (make-habitat)) ;; required for py-import # clpython(8): (setq m (py-import '(foo))) # clpython(9): (attr m 'f) ;; attribute lookup # clpython(10): (funcall *) 24 None Where foo.y is: def f(): print 24 - Willem From shapiro at cse.Buffalo.EDU Fri Jan 9 20:48:46 2009 From: shapiro at cse.Buffalo.EDU (Stuart C. Shapiro) Date: Fri, 09 Jan 2009 15:48:46 -0500 Subject: [clpython-devel] Calling Python functions from Lisp [Re Franz thread: spr35431] In-Reply-To: References: <49662240.1080703@cse.buffalo.edu> Message-ID: <4967B82E.4000309@cse.buffalo.edu> Willem, Thanks a lot. Your examples worked, and using them, I wrote a set of functions that seem to do what I want. I'll include them below, but first, here's a demo. The python file, called /projects/shapiro/clpython/test.py ----------------------------- # A Python file to use to test clpython def test(): print "I am a Python function." return "I am done." def pyplus(x,y): return x+y def pyminus(x,y): return x-y print("The Python test file has been run.") ----------------------------- My use of it, after loading CLPython and my new utility: ----------------------------- cl-user(3): :pwd Lisp's current working directory is "/home/csefaculty/shapiro/" *default-pathname-defaults* is #P"/home/csefaculty/shapiro/" cl-user(4): (clpython:pypaths "/projects/shapiro/clpython/") ("/projects/shapiro/clpython/") cl-user(5): (clpython:pyimport 'test) ; Fast loading /projects/shapiro/clpython/test.fasl The Python test file has been run. # cl-user(6): (* (clpython:pycall 'test 'pyplus 3 5) (clpython:pycall 'test 'pyminus 7 4)) 24 ----------------------------- My utility. It could probably be made more sophisticated. ----------------------------- ;;; Utility for calling Python Functions from Common Lisp ;;; Stuart C. Shapiro ;;; Uses CLPython ;;; and additional suggestions from Willem Broekema ;;; January 9, 2009 (in-package :clpython) (export '(pypaths pyimport pycall)) (setf *habitat* (make-habitat)) (defvar *pymodules* (make-hash-table) "A map from module names to module structures.") (defun pypaths (&rest paths) "Adds the paths to the list of paths that are tried when locating a module in order to import it." (setf cl-user::*clpython-module-search-paths* (append cl-user::*clpython-module-search-paths* paths))) (defun pyimport (module) ;; Imports the given Python module, and creates an entry for it in *pymodules*" (setf (gethash module *pymodules*) (py-import (list module)))) (defun pycall (module fn &rest args) "Calls the function named fn of the module named module on the given arguments, and returns what it returns." (unless (gethash module *pymodules*) (error "There is no loaded module named ~S." module)) (apply (attr (gethash module *pymodules*) fn) args)) ----------------------------- Thanks, again. stu Willem Broekema wrote: > Hello Stuart, welcome to the list. > > On Thu, Jan 8, 2009 at 4:56 PM, Stuart C. Shapiro > wrote: > >> cl-user(3): (clpython:run "import test; test.test()") >> Warning: *import-recompiled-files* = # >> Warning: /net/projects/shapiro/clpython/test.fasl not in >> # >> ; Fast loading /net/projects/shapiro/clpython/test.fasl >> [...] >> First question: Why the Warning messages? How can I get rid of them? >> > > Those were debug messages accidentally left in. They have been removed > now. Sorry about that. > > >> Notice that I can make use of the values returned by the Python function: >> ----------------------------- >> cl-user(4): (setf x (clpython:run "import test; test.test()")) >> Warning: *import-recompiled-files* = # >> Warning: /net/projects/shapiro/clpython/test.fasl not in >> # >> ; Fast loading /net/projects/shapiro/clpython/test.fasl >> The Python test file has been run. >> Warning: *import-recompiled-files* = # >> Warning: /net/projects/shapiro/clpython/test.fasl not in >> # >> I am a Python function. >> "I am done." >> >> cl-user(5): x >> "I am done." >> > > Yes, the last value of the Python expression is returned. > > >> What I'd really like to do now is to call test.test() as much as >> possible as though it were a Common Lisp function. One possible way is: >> ----------------------------- >> cl-user(6): (clpython:run "test.test()") >> Error: NameError: Variable `test' is unbound. >> [condition type: NameError] >> >> Restart actions (select using :continue): >> 0: Enter a Lisp value to use for `test'. >> 1: Return to Top Level (an "abort" restart). >> 2: Abort entirely from this (lisp) process. >> ----------------------------- >> But, the name of the function does not seem to survive from one call of >> clpython:run to another. >> >> Final question: How can I do this? >> > > There is not an elegent way for that yet (I'm working on it), but the > following works: > > cl-user(6): :pa clpython > clpython(7): (setf *habitat* (make-habitat)) ;; required for py-import > # > clpython(8): (setq m (py-import '(foo))) > # Src: /Users/willem/dev/lisp/tmp/git-clpython/foo.py > Binary: /Users/willem/.fasl/allegro-8.1m-macosx-x86/Users/willem/dev/lisp/tmp/git-clpython/foo.fasl > @ #x10a5a5a2> > clpython(9): (attr m 'f) ;; attribute lookup > # > clpython(10): (funcall *) > 24 > None > > Where foo.y is: > def f(): print 24 > > - Willem > -- Stuart C. Shapiro Professor, Department of Computer Science and Engineering University at Buffalo, The State University of New York 201 Bell Hall, Box 602000, Buffalo, NY 14260-2000, U.S.A. PHONE: 716-645-3180x125 FAX: 716-645-3464 shapiro at cse.buffalo.edu http://www.cse.buffalo.edu/~shapiro/ From shapiro at cse.Buffalo.EDU Fri Jan 9 21:54:23 2009 From: shapiro at cse.Buffalo.EDU (Stuart C. Shapiro) Date: Fri, 09 Jan 2009 16:54:23 -0500 Subject: [clpython-devel] Calling Python functions from Lisp [Re Franz thread: spr35431] In-Reply-To: References: <49662240.1080703@cse.buffalo.edu> <4967B82E.4000309@cse.buffalo.edu> Message-ID: <4967C78F.6050901@cse.buffalo.edu> Willem, That would be even better. Please let me know when it's done. In the meantime, what I have will do. stu Willem Broekema wrote: > On Fri, Jan 9, 2009 at 9:48 PM, Stuart C. Shapiro > wrote: > >> Thanks a lot. Your examples worked, and using them, I wrote a set of >> functions that seem to do what I want. I'll include them below, but >> first, here's a demo. >> > > Thanks for showing how you use this. Eventually I want to provide an > integration between Python and Lisp where Python functions can be > invoked just like Lisp functions without using attr and funcall, but > that's still in development. > > Let me know if there is anything more you need help with. > > Cheers, > - Willem > -- Stuart C. Shapiro Professor, Department of Computer Science and Engineering University at Buffalo, The State University of New York 201 Bell Hall, Box 602000, Buffalo, NY 14260-2000, U.S.A. PHONE: 716-645-3180x125 FAX: 716-645-3464 shapiro at cse.buffalo.edu http://www.cse.buffalo.edu/~shapiro/ From metawilm at gmail.com Fri Jan 9 21:42:39 2009 From: metawilm at gmail.com (Willem Broekema) Date: Fri, 9 Jan 2009 22:42:39 +0100 Subject: [clpython-devel] Calling Python functions from Lisp [Re Franz thread: spr35431] In-Reply-To: <4967B82E.4000309@cse.buffalo.edu> References: <49662240.1080703@cse.buffalo.edu> <4967B82E.4000309@cse.buffalo.edu> Message-ID: On Fri, Jan 9, 2009 at 9:48 PM, Stuart C. Shapiro wrote: > Thanks a lot. Your examples worked, and using them, I wrote a set of > functions that seem to do what I want. I'll include them below, but > first, here's a demo. Thanks for showing how you use this. Eventually I want to provide an integration between Python and Lisp where Python functions can be invoked just like Lisp functions without using attr and funcall, but that's still in development. Let me know if there is anything more you need help with. Cheers, - Willem From alan.bat at gmail.com Thu Jan 15 13:18:34 2009 From: alan.bat at gmail.com (Al Bat) Date: Thu, 15 Jan 2009 16:18:34 +0300 Subject: [clpython-devel] Can not login to cvspublic.franz.com Message-ID: <96a71df00901150518l6375870av33f27caad4633723@mail.gmail.com> Hi ! Sorry for asking such a stupid question. Is there any other way to download the current snapshot of CLPython? I've tried *"cvs -d :pserver:cvspublic at cvspublic.franz.com:/cvs-public login"* with password "* cvspublic*", as it was recommended. However, as a result, I receive only*"Connection refused" *from the server. I'm not sure, whether the failure is at the server's side. Can anybody confirm that this *cvs* way works. And in the case if it doesn't, can anybody be so kind to give me a hint on any alternative way of getting CLPython. By the way, how big is it? Maybe, it can be sent via email? Thanks! Al -------------- next part -------------- An HTML attachment was scrubbed... URL: From metawilm at gmail.com Thu Jan 15 14:08:49 2009 From: metawilm at gmail.com (Willem Broekema) Date: Thu, 15 Jan 2009 15:08:49 +0100 Subject: [clpython-devel] Can not login to cvspublic.franz.com In-Reply-To: <96a71df00901150518l6375870av33f27caad4633723@mail.gmail.com> References: <96a71df00901150518l6375870av33f27caad4633723@mail.gmail.com> Message-ID: Hi Al, welcome to the list. On Thu, Jan 15, 2009 at 2:18 PM, Al Bat wrote: > Sorry for asking such a stupid question. Is there any other way to download > the current snapshot of CLPython? I've tried "cvs -d > :pserver:cvspublic at cvspublic.franz.com:/cvs-public login" with password > "cvspublic", as it was recommended. However, as a result, I receive only > "Connection refused" from the server. I'm not sure, whether the failure is > at the server's side. It is working for me. Could you please try it once again? Maybe the server at Franz was temporarily offline or something. But if it fails again, please use the trace option, -t, and send me that trace. I'll look into it then. So the commands become: cvs -t -d :pserver:cvspublic at cvspublic.franz.com:/cvs-public login password: cvspublic cvs -t -d :pserver:cvspublic at cvspublic.franz.com:/cvs-public checkout clpython > Can anybody confirm that this cvs way works. And in > the case if it doesn't, can anybody be so kind to give me a hint on any > alternative way of getting CLPython. By the way, how big is it? Maybe, it > can be sent via email? If cvs fails again, I'll send you a zip file, okay? - Willem From alan.bat at gmail.com Thu Jan 15 14:57:45 2009 From: alan.bat at gmail.com (Al Bat) Date: Thu, 15 Jan 2009 17:57:45 +0300 Subject: [clpython-devel] Can not login to cvspublic.franz.com In-Reply-To: References: <96a71df00901150518l6375870av33f27caad4633723@mail.gmail.com> Message-ID: <96a71df00901150657n25d02263j519515b45bbe4deb@mail.gmail.com> Hi Willem! Thank you for your rapid reply and for making CLPython, which, I believe, should be THE proper implementation of Python! I've done what you kindly advised me to do. Tracing gave me the following: al at helen:~$ cvs -t -d :pserver:cvspublic at cvspublic.franz.com:/cvs-public > login > -> main: Session ID is IxeXwAXJJZG5tyyt > -> main loop with CVSROOT=/cvs-public > Logging in to :pserver:cvspublic at cvspublic.franz.com:2401/cvs-public > CVS password: > -> Connecting to cvspublic.franz.com(67.207.112.67):2401. > cvs [login aborted]: connect to cvspublic.franz.com(67.207.112.67):2401 > failed: Connection refused > Maybe, my IP was regarded suspictious by the firewall on the server side? No idea so far. If it works for everyone else, apart from me, it should be my problem. I'll think about it a bit more. Thank you anyway! If cvs fails again, I'll send you a zip file, okay? > Yes, if you could, please? That would be great! On Thu, Jan 15, 2009 at 5:08 PM, Willem Broekema wrote: > Hi Al, welcome to the list. > > On Thu, Jan 15, 2009 at 2:18 PM, Al Bat wrote: > > Sorry for asking such a stupid question. Is there any other way to > download > > the current snapshot of CLPython? I've tried "cvs -d > > :pserver:cvspublic at cvspublic.franz.com:/cvs-public login" with password > > "cvspublic", as it was recommended. However, as a result, I receive only > > "Connection refused" from the server. I'm not sure, whether the failure > is > > at the server's side. > > It is working for me. Could you please try it once again? Maybe the > server at Franz was temporarily offline or something. But if it fails > again, please use the trace option, -t, and send me that trace. I'll > look into it then. So the commands become: > > cvs -t -d :pserver:cvspublic at cvspublic.franz.com:/cvs-public login > password: cvspublic > cvs -t -d :pserver:cvspublic at cvspublic.franz.com:/cvs-public checkout > clpython > > > Can anybody confirm that this cvs way works. And in > > the case if it doesn't, can anybody be so kind to give me a hint on any > > alternative way of getting CLPython. By the way, how big is it? Maybe, it > > can be sent via email? > > If cvs fails again, I'll send you a zip file, okay? > > - Willem > -------------- next part -------------- An HTML attachment was scrubbed... URL: From metawilm at gmail.com Thu Jan 15 15:19:30 2009 From: metawilm at gmail.com (Willem Broekema) Date: Thu, 15 Jan 2009 16:19:30 +0100 Subject: [clpython-devel] Can not login to cvspublic.franz.com In-Reply-To: <96a71df00901150657n25d02263j519515b45bbe4deb@mail.gmail.com> References: <96a71df00901150518l6375870av33f27caad4633723@mail.gmail.com> <96a71df00901150657n25d02263j519515b45bbe4deb@mail.gmail.com> Message-ID: On Thu, Jan 15, 2009 at 3:57 PM, Al Bat wrote: > Hi Willem! > Thank you for your rapid reply and for making CLPython, which, I believe, > should be THE proper implementation of Python! Thanks for being so positive. Do you have any special interest in this project? > I've done what you kindly advised me to do. Tracing gave me the following: All right, I've forwarded that to Franz. I'll send you the source in a separate email. - Willlem From metawilm at gmail.com Sat Jan 17 11:23:01 2009 From: metawilm at gmail.com (Willem Broekema) Date: Sat, 17 Jan 2009 12:23:01 +0100 Subject: [clpython-devel] CMUCL now also supported Message-ID: CLPython now also runs on CMUCL Snapshot 2009-01 (19E). This is in addition to the already supported implementations: Allegro CL, Lispworks and SBCL. Does anyone have a strong wish to have CLPython ported to yet another implementation? - Willem From jdn at math.carleton.ca Sat Jan 17 14:31:41 2009 From: jdn at math.carleton.ca (Jason Nielsen) Date: Sat, 17 Jan 2009 09:31:41 -0500 (EST) Subject: [clpython-devel] CMUCL now also supported In-Reply-To: References: Message-ID: On Sat, 17 Jan 2009, Willem Broekema wrote: > CLPython now also runs on CMUCL Snapshot 2009-01 (19E). > This is in addition to the already supported implementations: Allegro > CL, Lispworks and SBCL. > > Does anyone have a strong wish to have CLPython ported to yet another > implementation? > > - Willem > Hi Willem, Great work! The only implementation that I can think of that might be useful (to me) is ecl but it isn't a major request as I primarily use sbcl. Any hint of what the next steps for clpython are? Just curious ;-)! Thanks for creating clpython, Jason From metawilm at gmail.com Sat Jan 17 17:58:57 2009 From: metawilm at gmail.com (Willem Broekema) Date: Sat, 17 Jan 2009 18:58:57 +0100 Subject: [clpython-devel] Creating executables from Python functions (SBCL) Message-ID: It's now possible to create standalone executables from Python functions with SBCL (and only tested on Mac OS X). It is implemented on top of SBCL's function save-lisp-and-die. Using this functionality is straightforward: just call the method _exe() of the function. Example: * (clpython:repl) Welcome to CLPython, an implementation of Python in Common Lisp. Running on: SBCL 1.0.20 REPL shortcuts: `:q' = quit, `:h' = help. >>> def f(): print "hello world" ... # >>> f() hello world None >>> f._exe() Building executable will terminate the Lisp session. Continue? (y or n) y Writing SBCL repl executable to: clpython-sbcl-20090105-f [undoing binding stack and other enclosing state... done] [saving current Lisp image into /Users/willem/dev/lisp/tmp/test-python/python/clpython-sbcl-20090105-f: writing 2872 bytes from the read-only space at 0x04000000 writing 1616 bytes from the static space at 0x04100000 writing 29245440 bytes from the dynamic space at 0x10000000 done] [willem test-python]$ ls -l ./python/clpython-sbcl-20090105-f -rwxr-xr-x 1 willem willem 29462540 Jan 17 18:50 ./python/clpython-sbcl-20090105-f [willem test-python]$ ./python/clpython-sbcl-20090105-f hello world [willem test-python]$ The executables have access to the command line arguments via "sys.argv". That should make it straightforward to write small utility programs. Here is an example program that takes input from the command line. Type it all in the repl: import sys def fact(n): if n <= 1: return 1 else: return n * fact(n-1) def main(): # read argument from command line, using 10 as default if len(sys.argv) > 0: n = int(sys.argv[0]) else: n = 10 print "fact(%s):" % n print fact(n) main._exe() This gives an executable that behaves like this: [willem test-python]$ ./python/clpython-sbcl-20090105-main fact(10): 3628800 [willem test-python]$ ./python/clpython-sbcl-20090105-main 20 fact(20): 2432902008176640000 - Willem From metawilm at gmail.com Sat Jan 17 18:12:44 2009 From: metawilm at gmail.com (Willem Broekema) Date: Sat, 17 Jan 2009 19:12:44 +0100 Subject: [clpython-devel] CMUCL now also supported In-Reply-To: References: Message-ID: On Sat, Jan 17, 2009 at 3:31 PM, Jason Nielsen wrote: > Great work! The only implementation that I can think of that might be > useful (to me) is ecl but it isn't a major request as I primarily use > sbcl. Okay, I'll wait until there is demand for it. > Any hint of what the next steps for clpython are? Just curious ;-)! A few things that play: - Getting the shootout benchmark running . The result of the tests that can be run is that CLPython performance is not bad, but CPython is on average a bit faster. - Running Sympy, a big pure-Python project, to show language completeness. Attempting this lead already to many small fixes and conversion of required Python standard library files. - A future goal is to have an Emacs IDE for Python based on Slime. In particular I'd like to have a great debugger for stepping through Python code. If anyone has good ideas or wishes for this, let me know. - Willem From jdn at math.carleton.ca Sat Jan 17 21:48:07 2009 From: jdn at math.carleton.ca (Jason Nielsen) Date: Sat, 17 Jan 2009 16:48:07 -0500 (EST) Subject: [clpython-devel] CMUCL now also supported In-Reply-To: References: Message-ID: On Sat, 17 Jan 2009, Willem Broekema wrote: >> Any hint of what the next steps for clpython are? Just curious ;-)! > > A few things that play: > > - Getting the shootout benchmark running > . The result of the tests that can > be run is that CLPython performance is not bad, but CPython is on > average a bit faster. Interesting! Do you think this is because most of the CPython code in the benchmark relies on library functions that are compiled C code? Have you thought about adding optional types to CLPython (a.l.a. PEP 3107 in Python 3.0)? If these expanded to type declarations in common lisp I think the performance could be improved significantly.... all speculation of course! > - Running Sympy, a big pure-Python project, to show language > completeness. Attempting this lead already to many small fixes and > conversion of required Python standard library files. Sweet... and something I'd find quite useful to boot! > - A future goal is to have an Emacs IDE for Python based on Slime. In > particular I'd like to have a great debugger for stepping through > Python code. If anyone has good ideas or wishes for this, let me know. Sounds great! Thanks for the list of goodness to come. Jason From metawilm at gmail.com Mon Jan 19 15:43:24 2009 From: metawilm at gmail.com (Willem Broekema) Date: Mon, 19 Jan 2009 16:43:24 +0100 Subject: [clpython-devel] CMUCL now also supported In-Reply-To: References: Message-ID: On Sat, Jan 17, 2009 at 10:48 PM, Jason Nielsen wrote: >> - Getting the shootout benchmark running >> . The result of the tests that can >> be run is that CLPython performance is not bad, but CPython is on >> average a bit faster. > > Interesting! Do you think this is because most of the CPython code in the > benchmark relies on library functions that are compiled C code? Some of the shootout benchmarks say more about the Lisp implementation than about CLPython: bintrees.py checks the speed of recursion and consing; chameneos-redux.py check the speed of acquiring and releasing process locks. But there are others that say more about Python implementation speed. Once the shootout files can be run on CLPython, I intend to add the shootout files to the CLPython distribution, with a simple function to run them and at the same time run them in CPython. > Have you thought about adding optional types to CLPython (a.l.a. PEP 3107 in > Python 3.0)? If these expanded to type declarations in common lisp I think > the performance could be improved significantly.... all speculation of > course! That PEP only introduces the concept of annotations, not the semantics. And those semantics are not clear to me. For example, what should it mean to say "x" is an "int"? - how many bits does it have? - does it overflow? - can it be an instance of a user-defined subclass of int? - can "x" is unbound at some point, causing a NameError? This is also what I dislike about Cython: instead of basing numeric declarations on C number types, it would be so much more portable and smart to declare the range of the values: x is in (0 .. whatever). If anyone feels the urge to aid in development, please take a look at the Python standard library, take one implemented in C, and try to convert that to Lisp. In clpython/lib/ is a start. Cheers, - Willem