Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > optional static typing for Python

Reply
Thread Tools

optional static typing for Python

 
 
Boris Borcic
Guest
Posts: n/a
 
      01-28-2008
Wish you'd opted out of typing all that static.

BB

Russ P. wrote:
(...)
>
> What is that supposed to mean?
>
> Oh, I almost forgot. I'm supposed to sit here and be polite while
> clueless dolts make wise cracks. Sorry, but I haven't yet mastered
> that level of self-control.
>
> I would just like to thank you for reminding me about what losers hang
> out perpetually on sites like this one, thinking they are in some kind
> of real "community." Being reminded of that will help prevent me from
> becoming such a loser myself. No, I didn't say that all the "regulars"
> here are losers, but you most certainly are.
>
> Do you have a job? How about a life? Have you ever been "with" a
> woman? How in the world is it that every time I come to this site, I
> see your sorry ass hanging around yet again? I can't even imagine how
> "pointless" your life must be if you have that much time to spend
> "hanging around" on comp.lang.python -- and being an a--hole to boot.
>
> Yeah, Lord have mercy -- on losers like you.
>
> And thanks for reminding me to quit wasting so much time here. I've
> been doing way too much of that lately.

 
Reply With Quote
 
 
 
 
Marc 'BlackJack' Rintsch
Guest
Posts: n/a
 
      01-28-2008
On Mon, 28 Jan 2008 08:31:43 -0800, John Nagle wrote:

> Unenforced static typing is somewhat pointless. If that
> goes in, it should be enforced by implementations.


Luckily we don't get static typing. We get annotations which *can* be
used for type hints, checked by additional code. Can be used for other
things as well.

Ciao,
Marc 'BlackJack' Rintsch
 
Reply With Quote
 
 
 
 
Arnaud Delobelle
Guest
Posts: n/a
 
      01-28-2008
On Jan 28, 4:31*pm, John Nagle <(E-Mail Removed)> wrote:
> Arnaud Delobelle wrote:

[...]
> > Note that annotations do not provide explicit typing, AFAIK:

>
> > def f(x:int) -> int: return x*2

>
> > is stricly equivalent to

>
> > def f(x): return x*2
> > f.__annotations__ = {'x':int, 'return':int}

>
> > You still need to write a type-checking wrapper.

>
> * * Unenforced static typing is somewhat pointless. *If that
> goes in, it should be enforced by implementations. *Otherwise,
> maintenance programmers can't trust the type information they see.


(As discussed earlier, there is no static typing in Python, there can
only be runtime type-checking or, as someone called it, "explicit
typing")
I think the idea is to let the user decide how to enforce type-
checking, not the language. I suppose if in a few years a way to do
it emerges that is "the best", then it'll make its way into the
standard library...

--
Arnaud

 
Reply With Quote
 
Ben Finney
Guest
Posts: n/a
 
      01-29-2008
"Russ P." <(E-Mail Removed)> writes:

> I would just like to thank you for reminding me about what losers
> hang out perpetually on sites like this one, thinking they are in
> some kind of real "community." Being reminded of that will help
> prevent me from becoming such a loser myself. No, I didn't say that
> all the "regulars" here are losers, but you most certainly are.


We're a community largely because we don't tolerate this level of
content-free insult. Please find a different forum for this stuff.

--
\ "We spend the first twelve months of our children's lives |
`\ teaching them to walk and talk and the next twelve years |
_o__) telling them to sit down and shut up." -- Phyllis Diller |
Ben Finney
 
Reply With Quote
 
Chris Mellon
Guest
Posts: n/a
 
      01-29-2008
On Jan 28, 2008 10:31 AM, John Nagle <(E-Mail Removed)> wrote:
> Arnaud Delobelle wrote:
> > On Jan 27, 11:00 pm, "Russ P." <(E-Mail Removed)> wrote:
> >> On Jan 27, 2:49 pm, "André" <(E-Mail Removed)> wrote:
> >>> Perhaps this:http://www.python.org/dev/peps/pep-3107/mightbe
> >>> relevant?
> >>> André
> >> Thanks. If I read this correctly, this PEP is on track for Python 3.0.
> >> Wonderful!

> >
> > Note that annotations do not provide explicit typing, AFAIK:
> >
> > def f(x:int) -> int: return x*2
> >
> > is stricly equivalent to
> >
> > def f(x): return x*2
> > f.__annotations__ = {'x':int, 'return':int}
> >
> > You still need to write a type-checking wrapper.

>
> Unenforced static typing is somewhat pointless. If that
> goes in, it should be enforced by implementations. Otherwise,
> maintenance programmers can't trust the type information they see.
>
> Enforced, it makes it possible to start getting serious about
> optimizing compilers for Python, like Shed Skin. Shed Skin
> can usually figure out typing within a module, but across module
> boundaries, some help is needed if you want to push optimization from
> run time to compile time.
>

Given the difficulty of statically analyzing Python, and the
limitations you need to add for either static typing or type inference
to be practical, I think that the real future for faster Python code
is JIT, not static optimizations. Languages which enforce static
typing are, of course, not Python - that's why they have different
names, like Pyrex or ShedSkin or RPython.

I think static Python is pretty much a waste of time, really - if I'm
going to write statically typed code using a traditional C/C++/Java
style type system, I'll use a language designed for it, like D. If I
want *real* strict typing - the kind where you can actually make a
useful inference from the fact that the program is type-correct - I'll
use Haskell or Ocaml. There is a lot of choice out there and there's
no reason to try to make Python into whatever your favorite paradigm
is.
 
Reply With Quote
 
Kay Schluehr
Guest
Posts: n/a
 
      01-29-2008
On 29 Jan., 17:00, "Chris Mellon" <(E-Mail Removed)> wrote:

> Given the difficulty of statically analyzing Python, and the
> limitations you need to add for either static typing or type inference
> to be practical, I think that the real future for faster Python code
> is JIT, not static optimizations.


Python has a JIT right now - so why do you think it's Pythons "real
future"?

 
Reply With Quote
 
Wildemar Wildenburger
Guest
Posts: n/a
 
      01-29-2008
> Python has a JIT right no
>

You mean in the Java-sense (outputting native machine code)?

/W
 
Reply With Quote
 
bruno.desthuilliers@gmail.com
Guest
Posts: n/a
 
      01-30-2008
On 28 jan, 11:21, "Russ P." <(E-Mail Removed)> wrote:
> On Jan 28, 1:53 am, Bruno Desthuilliers <bruno.
>
>
>
> (E-Mail Removed)> wrote:
> > Russ P. a écrit :

>
> > > On Jan 27, 5:03 pm, Paddy

>
> > >> If static typing is optional then a program written in a dynamic
> > >> language that passes such an automated static analysis of source code
> > >> would have to be a simple program written in a simplistic way, and
> > >> also in a static style.

>
> > > Yes, but for safety-critical software you usually want the simplest
> > > possible solution. The last think you want is an unnecessarily "fancy"
> > > design. Unless there is a darn good reason to write a "non-static"
> > > program, you just don't do it.

>
> > > You might want to check into what the FAA allows in "flight-critical"
> > > code, for example. I am certainly not an expert in that area, but I've
> > > had a passing exposure to it. My understanding is that every possible
> > > branch of the code must be fully and meticulously analyzed and
> > > verified. Hence, the dynamic dispatching of ordinary object-oriented
> > > code is either prohibited or severely frowned upon.

>
> > Then Python is definitively out, so this whole thread is pointless.

>
> Yes, Python as it stands now is "definitely out" as the ultimate
> implementation language for flight-critical software. That's
> essentially a no-brainer. But it can certainly be useful as a
> prototyping language for R&D.
>
> The question then arises as to how to best make use of the prototype.
> Do you throw away the code and start from scratch? That doesn't seem
> wise to me. But maybe that's because I have some idea of how much
> effort can go into developing a good prototype.
>
> If Python could be automatically converted to Ada or Java, that could
> potentially be used as a baseline for actual operational software.
> That would capture the algorithmic details more reliably than recoding
> from scratch by hand. But such an automatic conversion is not feasible
> without explicit typing.


As far as I can tell, this should be possible using type annotations
and some "soft" (ie: coding style guideline) restrictions on the most
dynamic features. This may even be possible without type annotation,
if I refer to the work being done on RPython for Pypy.

This being said, I don't personaly believe that much in "automatic
conversion" from Python to Java or Ada, because a language is not only
made of a syntax and grammar, but also of idioms, and I really doubt
you'll get idiomatic Java or Ada from idiomatic Python - unless your
Python code is written in Javaish (or Ada-ish) idioms, in which case
using Python is IMHO, well, how to say... somewhat pointless ?-)

> And speaking of "pointless," ... I just wasted a significant amount of
> time replying to a pointless post. Oh, well.


Coming from someone posting here that declarative static typing would
make a better Python just because *he* thinks he have a need for it,
without any consideration for the fact that most people here use
Python because they don't actually want static typing, and without
even realizing that most of what makes Python great for prototyping is
it's dynamism, I do find this use of terms like "pointless" and "waste
of time" *very* amusing. Almost as amusing as this other post where
you so kindly worried about my job and personal life.

 
Reply With Quote
 
Kay Schluehr
Guest
Posts: n/a
 
      01-30-2008
On Jan 30, 12:38 am, Wildemar Wildenburger
<(E-Mail Removed)> wrote:
> > Python has a JIT right no

>
> You mean in the Java-sense (outputting native machine code)?
>
> /W


Sure.

http://psyco.sourceforge.net/


 
Reply With Quote
 
Wildemar Wildenburger
Guest
Posts: n/a
 
      01-30-2008
Kay Schluehr wrote:
> On Jan 30, 12:38 am, Wildemar Wildenburger
> <(E-Mail Removed)> wrote:
>>> Python has a JIT right no

>> You mean in the Java-sense (outputting native machine code)?
>>
>> /W

>
> Sure.
>
> http://psyco.sourceforge.net/
>


Oh, switcheroo!

/W
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Status of optional static typing in Python? Christian Convey Python 6 06-23-2006 12:22 PM
Optional Static Typing bearophileHUGS@lycos.com Python 50 01-04-2005 03:02 PM
Re: Koolaid (was Re: Optional Static Typing) Tim Churches Python 2 12-24-2004 01:18 PM
Guido & Optional Static Typing Luis M. Gonzalez Python 1 12-24-2004 01:58 AM
Optional static typing (or, What can Ruby 2.0 borrow from Boo?) Daniel Berger Ruby 22 12-01-2004 09:26 PM



Advertisments