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


Groups > comp.lang.python > #18430

Re: python philosophical question - strong vs duck typing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feeder.erje.net!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <darcy@druid.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'sure.': 0.05; ':-)': 0.06; 'everybody,': 0.07; 'python': 0.08; '"a"': 0.09; '425': 0.09; 'command.': 0.09; 'subject:python': 0.10; 'c++': 0.12; 'typing': 0.15; 'everything)': 0.16; 'glue': 0.16; 'im:': 0.16; 'question.': 0.16; 'subject:question': 0.17; 'language': 0.17; 'wrote:': 0.18; 'contribute': 0.18; 'example.': 0.18; 'voting': 0.18; 'accepting': 0.19; 'convert': 0.19; 'seems': 0.20; 'written': 0.20; 'to:2**1': 0.21; 'header:In-Reply-To:1': 0.22; 'welcome.': 0.23; 'command': 0.24; 'tests': 0.25; 'module': 0.26; "i'm": 0.26; 'function': 0.27; 'fix': 0.27; 'coding': 0.28; "wasn't": 0.28; 'compile': 0.29; 'script.': 0.29; 'sean': 0.29; 'pm,': 0.29; 'closer': 0.30; 'for,': 0.30; 'quickly.': 0.30; 'pure': 0.32; 'pretty': 0.32; 'header:User-Agent:1': 0.33; 'there': 0.33; 'together.': 0.34; 'to:addr:python-list': 0.34; 'probably': 0.34; 'it.': 0.34; 'certain': 0.34; 'restrict': 0.34; 'changing': 0.35; 'to:no real name:2**1': 0.35; 'ourselves': 0.35; 'especially': 0.35; 'project': 0.35; 'however,': 0.36; 'question': 0.36; 'subject:skip:p 10': 0.37; 'but': 0.37; 'run': 0.37; 'machine': 0.37; 'received:192': 0.37; "there's": 0.37; 'another': 0.37; 'using': 0.38; 'somewhat': 0.38; 'some': 0.38; 'put': 0.38; 'option': 0.39; 'being': 0.39; 'else': 0.39; 'strong': 0.39; "it's": 0.40; 'to:addr:python.org': 0.40; 'might': 0.40; 'received:192.168': 0.40; 'url:net': 0.60; 'more': 0.61; 'type': 0.61; 'worth': 0.61; 'your': 0.61; 'efficient': 0.62; 'back': 0.62; 'you.': 0.63; 'believe': 0.65; '"do': 0.67; 'gain': 0.75; 'democracy': 0.84; 'received:98.158': 0.84; 'seldom': 0.84; 'drive.': 0.91; 'was.': 0.93
Date Tue, 03 Jan 2012 13:50:43 -0500
From D'Arcy Cain <darcy@druid.net>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version 1.0
To python-list@python.org, ether.joe@gmail.com
Subject Re: python philosophical question - strong vs duck typing
References <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com>
In-Reply-To <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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.4366.1325616656.27778.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325616656 news.xs4all.nl 6875 [2001:888:2000:d::a6]:33643
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18430

Show key headers only | View raw


On 12-01-03 01:13 PM, Sean Wolfe wrote:
> Hello everybody, I'm a happy pythonista newly subscribed to the group.

Welcome.

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

That's "a" question.  "The" question is "do you want to?"  Since we 
already run in machine language (doesn't everything) then how can you be 
sure that introducing another layer will improve performance?

> 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.

Where is your bottleneck?  I have seldom found Python to be it. 
Remember, almost everything you run was written in C.  Python is just 
the glue that binds it all together.

Consider ls(1) (dir in Windows/DOS) for example.  If you need a 
directory listing you type that and get it pretty quickly.  Is there a 
bottleneck?  Yes, it's you.  The command can probably do all of its work 
much faster than you can type the command.  Now put the command into a 
script.  Entering the command is no longer the bottleneck.  It's now the 
time it takes to access the drive.  Do we care?  Probably not and if we 
did there's probably not much we can do about it.  Python is simply a 
more powerful and efficient way to get to that machine language in a script.

If you do have a pure Python function that is a bottleneck and you 
believe that C can solve it, you can always write just that part in C. 
However, run some tests first to make sure.  99% of the time you can fix 
it algorithmically or else it wasn't the bottleneck that you thought it 
was.  And if it is and no one has already written a module for it, you 
just found a project to contribute back to the community.  :-)

> It seems to be that accepting the restrictions of strong typing might
> be worth it in certain circumstances. Basically the option to use a

So few as to not be worth changing the language for, especially when C 
is always available if you need it.

Cheers.

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
IM: darcy@Vex.Net

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


Thread

Re: python philosophical question - strong vs duck typing D'Arcy Cain <darcy@druid.net> - 2012-01-03 13:50 -0500

csiph-web