Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18427

Re: python philosophical question - strong vs duck typing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <nathan.alexander.rice@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.04; 'desired.': 0.07; 'everybody,': 0.07; 'whatever.': 0.07; 'wrapper': 0.07; 'python': 0.08; 'necessary,': 0.09; 'subject:python': 0.10; 'c++': 0.12; 'typing': 0.15; '1:13': 0.16; 'declaring': 0.16; 'subject:question': 0.17; 'language': 0.17; 'wrote:': 0.18; 'accepting': 0.19; 'convert': 0.19; 'jan': 0.19; 'this?': 0.19; 'seems': 0.20; 'header:In-Reply-To:1': 0.22; 'implicit': 0.23; 'extent': 0.24; 'static': 0.24; 'code': 0.25; "i'm": 0.26; 'variable': 0.28; 'coding': 0.28; 'message- id:@mail.gmail.com': 0.28; 'compile': 0.29; 'sean': 0.29; 'theoretical': 0.29; 'pm,': 0.29; 'closer': 0.30; 'compromise': 0.30; 'types.': 0.30; 'yes.': 0.30; 'does': 0.32; 'tue,': 0.32; "isn't": 0.33; 'there': 0.33; 'received:209.85.160': 0.33; 'to:addr:python-list': 0.34; 'it.': 0.34; 'mostly': 0.34; 'certain': 0.34; 'anything': 0.34; 'declared': 0.34; 'restrict': 0.34; 'changing': 0.35; 'ourselves': 0.35; 'received:209.85.160.46': 0.35; 'received:mail- pw0-f46.google.com': 0.35; 'project': 0.35; 'question': 0.36; 'uses': 0.36; 'subject:skip:p 10': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'doing': 0.38; 'using': 0.38; 'somewhat': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'option': 0.39; 'being': 0.39; 'everyone': 0.39; 'strong': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'might': 0.40; 'more': 0.61; 'type': 0.61; 'types': 0.61; 'worth': 0.61; 'your': 0.61; 'enable': 0.62; 'forward': 0.63; 'our': 0.64; '2012': 0.67; 'gain': 0.75; 'casting': 0.84; 'nathan': 0.84; 'niche': 0.91; 'going?': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ymvmvVpd5uZfWbyNgMlCAUfCsBGN9J+k45eMBNzJd4o=; b=rx2XxJmnE1ocraqZDVZ9Rt1rnUsFZcwriN/JXmf3LJsMQye4TIrFjM092o5VDTIX/2 4cx/cWOQFhXmRxT9AdQ3pgqOUcY1+E4uNf322Cpsne9Xown+XwYh9BQh/Deu8yx/4fhu rjiTvrqs3s2bV+Pk3PLJYkQhRietwISHP5rt8=
MIME-Version 1.0
In-Reply-To <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com>
References <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com>
Date Tue, 3 Jan 2012 13:28:51 -0500
Subject Re: python philosophical question - strong vs duck typing
From Nathan Rice <nathan.alexander.rice@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4363.1325615334.27778.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325615334 news.xs4all.nl 6927 [2001:888:2000:d::a6]:48779
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18427

Show key headers only | View raw


On Tue, Jan 3, 2012 at 1:13 PM, Sean Wolfe <ether.joe@gmail.com> wrote:
> Hello everybody, I'm a happy pythonista newly subscribed to the group.
> How is it going?
> I have a theoretical / philosophical question regarding strong vs duck
> typing in Python. Let's say we wanted to type strongly in Python and
> 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.

Do you think everyone who uses the code you write wants to deal with
your type decisions?

> The question is, given this possibility, would this get us closer to
> being able to compile down to a language like C or C++?

Declaring types would enable some additional optimizations, yes.  No,
it isn't worth it.

> What I am driving at is, if we are coding in python but looking for
> more performance, what if we had an option to 1) restrict ourselves
> somewhat by using strong typing to 2) make it easy to compile or
> convert down to C++ and thereby gain more performance.

Take a look at PyPy, with RPython.  That is the most future proof,
forward thinking way of doing what you want.

> It seems to be that accepting the restrictions of strong typing might
> be worth it in certain circumstances. Basically the option to use a
> strongly-typed Python as desired. Does this get us closer to being
> able to convert to Cpp? Does the Cython project have anything to do
> with this?

Declared typing is mostly annoying.  Implicit static typing is less
annoying, but still has issues.

Cython fills the same niche as PyPy's Rpython.  Use it if you have a
lot of C code you want to call, as you will get better performance
than a wrapper like SWIG.

Nathan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: python philosophical question - strong vs duck typing Nathan Rice <nathan.alexander.rice@gmail.com> - 2012-01-03 13:28 -0500

csiph-web