python philosophical question - strong vs duck typing

Devin Jeanpierre jeanpierreda at gmail.com
Tue Jan 3 16:06:24 EST 2012


> Python objects are strongly typed, in any sensible meaning of the term.

There are people that hold definitions of strong typing that preclude
Python. Those people think their definition is reasonable, but at the
same time haven't confused static typing with strong typing. I guess
the problem is that this boils down to opinion, but you're stating it
as incontrovertible fact.

> What you mean is statically or explicitly typing names.

Right, yes.

> Cython compiles Python as is to C. It also gives the option to add type
> annotations to names to get faster code. Shredskin compiles a subset of
> Python, or a subset of usages, to C, with similar benefits.

I seem to remember there being a project which compiled the Python
bytecode down to C in a very dumb way (basically just making C code
that creates the bytecode and executes it in the CPython VM). I can't
find it, though.

Anyway, compiling Python to C is actually fairly trivial. People
usually mean something else by it, though.

-- Devin

On Tue, Jan 3, 2012 at 3:38 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 1/3/2012 1:13 PM, Sean Wolfe wrote:
>
>> I have a theoretical / philosophical question regarding strong vs duck
>> typing in Python. Let's say we wanted to type strongly in Python and
>
>
> Python objects are strongly typed, in any sensible meaning of the term.
> What you mean is statically or explicitly typing names.
>
>
>> were willing to compromise our code to the extent necessary, eg not
>> changing variable types or casting or whatever. Let's say there was a
>> methodology in Python to declare variable types.
>>
>> The question is, given this possibility, would this get us closer to
>> being able to compile down to a language like C or C++?
>
>
> Cython compiles Python as is to C. It also gives the option to add type
> annotations to names to get faster code. Shredskin compiles a subset of
> Python, or a subset of usages, to C, with similar benefits.
>
> --
> Terry Jan Reedy
>
> --
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list