[pypy-dev] Re: psyco in Python was: Minimal Python project
logistix at zworg.com
Sat Jan 18 18:50:25 CET 2003
> If I am wrong, the counter-example should provide a _clear reason_ why all
> my arguments above are wrong. And wouldn't that be great :-) I believe the
> arguments given should be given greater weight than the "psyco has more
> knowledge" mantra. You want to convince me otherwise? Show me the code, or
> provide a _detailed_ explanation for how my arguments do not apply.
Firstly, C compilation is static. Secondly, python can do plenty of
stuff that can't be easily transliterated into C. I doubt any current C
compilers would be able to optimize a C version of the following code
(regardless of the practicality of it)...
PythonWin 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on
Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) -
see 'Help/About PythonWin' for further copyright information.
>>> def crazyRPC_getAge(username):
.. Pretend this is a real RPC call,
.. and a black box to the compiler.
.. if username == "Bob":
.. return 23 #int
.. elif username == "Doug":
.. return 12.5 #float
.. raise Exception("Unknown user %s" % username)
>>> def drinkingAge(age):
.. def test():
.. return age >= 21
.. return test
>>> bobCanDrink = drinkingAge(crazyRPC_getAge("Bob")) #returns function optimized for ints
>>> dougCanDrink = drinkingAge(crazyRPC_getAge("Doug")) #returns function optimized for floats
More information about the Pypy-dev