python philosophical question - strong vs duck typing

Terry Reedy tjreedy at
Tue Jan 3 15:38:17 EST 2012

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

More information about the Python-list mailing list