why () is () and [] is [] work in other way?

Devin Jeanpierre jeanpierreda at gmail.com
Thu Apr 26 23:09:53 EDT 2012


On Thu, Apr 26, 2012 at 7:33 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Thu, 26 Apr 2012 12:22:55 -0700, Adam Skutt wrote:
>
>> I often wonder what the world would be like if Python, C#, and Java
>> embraced value types more, and had better support for pure functions.
>
> They would be slower, require more memory, harder to use, and far, far
> less popular.

That's odd. PyPy supports value types and pure functions as a
performance optimization.

For reference, see e.g.

http://morepypy.blogspot.ca/2011/03/controlling-tracing-of-interpreter-with_15.html
http://morepypy.blogspot.ca/2011/08/visualization-of-jitted-code.html

PyPy can detect some pure functions (or purity annotations) and can
run them at (JIT-)compile-time to speed up the runtime. Also, JIT'd
code uses unboxed values, rather than objects. (So it can unbox
something once, then do all the arithmetic, then box again).

(Of course, this is only a special case of a value type, as far as I
understand the term. But hey!)


Also somebody else was talking about Haskell being crazy fast, but if
you want a really fast functional language, take a look at ATS (an ML
variant). (Also pay close attention to the "bytes of code" comparison
-- it's rare one sees a language more verbose than C)

http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ats&lang2=gcc

-- Devin



More information about the Python-list mailing list