Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18427
| References | <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com> |
|---|---|
| Date | 2012-01-03 13:28 -0500 |
| Subject | Re: python philosophical question - strong vs duck typing |
| From | Nathan Rice <nathan.alexander.rice@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4363.1325615334.27778.python-list@python.org> (permalink) |
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
Re: python philosophical question - strong vs duck typing Nathan Rice <nathan.alexander.rice@gmail.com> - 2012-01-03 13:28 -0500
csiph-web