Python - SPARCS

coordinatedcapableSoftware and s/w Development

Nov 4, 2013 (3 years and 7 months ago)

89 views

Python

Guido van Rossum

Sung
-
Jin Hong

SPARCS

http://www.python.org

Slide
2



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

What’s in a name?


Snake logos and mascot notwithstanding,
it’s named after
Monty Python’s Flying
Circus


Humor
-
impaired can safely ignore the
spam references :
-
)


Nobody

expects the Spanish inquisition

Slide
3



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

What is Python?


O
-
O rapid prototyping language


Not just a scripting language


Not just another Perl


Easy to learn, read, use


Extensible (add new modules)


C/C++/Fortran/whatever


Java (through Jython)


Embeddable in applications

Slide
4



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Touchy
-
feely

properties


Open Source (OSI Certified)


copyrighted but use not restricted


no "viral" license


owned by independent non
-
profit, PSF


Mature (13 years old)


Supportive user community


plenty of good books, too


Simple design, easy to learn


reads like “pseudo
-
code”


Suitable as first language


Suitable as last language :
-
)

Slide
5



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

High
-
level properties


Extremely portable


Unix/Linux, Windows, Mac, PalmOS, WindowsCE,
RiscOS, VxWorks, QNX, OS/2, OS/390, AS/400,
PlayStation, Sharp Zaurus, BeOS, VMS…


Compiles to interpreted byte code


compilation is implicit and automatic


Memory management automatic


reference counting for most situations


GC added for cycle detection


“Safe”: no core dumps due to your bugs

Slide
6



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

What is it used for?


rapid prototyping


web programming (client and server side)


ad hoc programming ("scripting")


steering scientific applications


extension language


XML processing


database applications


GUI applications


education

Slide
7



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Who is using it?


Google (various projects)


NASA (several projects)


NYSE (one of only three languages "on the floor")


Industrial Light & Magic (everything)


Yahoo! (Yahoo mail & groups)


RealNetworks (function and load testing)


RedHat (Linux installation tools)


LLNL, Fermilab (steering scientific applications)


Zope Corporation (content management)


ObjectDomain (embedded Jython in UML tool)


Alice project at CMU (accessible 3D graphics)


More success stories at
www.pythonology.com

Slide
8



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Language properties


Everything is an object


Packages, modules, classes, functions


Exception handling


Dynamic typing, polymorphism


Static scoping


Operator overloading


Indentation for block structure


Otherwise conventional syntax

Slide
9



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

High
-
level data types


Numbers: int, long, float, complex


Strings, Unicode: immutable


Lists and dictionaries: containers


Other types for e.g. binary data, regular
expressions, introspection


Extension modules can define new

“built
-
in” data types

Slide
10



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Interfaces to...


XML


DOM, expat


XMLRPC, SOAP, Web Services


Relational databases


MySQL, PostgreSQL, Oracle , ODBC, Sybase, Informix


Java (via Jython)


Objective C


COM, DCOM (.NET too)


Many GUI libraries


cross
-
platform


Tk, wxWindows, GTK, Qt


platform
-
specific


MFC, Mac (classic, Cocoa), X11

Slide
11



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Compared to Perl


Easier to learn


very important for infrequent users


More readable code


More maintainable code


Fewer “magical” side effects


More “safety” guarantees


Better Java integration

Slide
12



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Compared to Java


Code up to 5 times shorter


and more readable


Dynamic typing


Multiple inheritance, operator overloading


Quicker development


no compilation phase


less typing


Yes, it may run a bit slower


but development is much faster


and Python uses less memory (studies show)

Similar (but more so) for C/C++

Slide
13



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Jython


Seamless integration with Java


Separate implementation


Implements the same language


Different set of standard modules


differences in “gray areas”


e.g. some different introspection calls


different command line options, etc.

Slide
14



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Jython's Java integration


Interactive


Compiles directly to Java bytecode


Import Java classes directly


Subclass Java classes


pass instances back to Java


Java beans integration


Can compile into Java class files

Slide
15



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

IronPython


Seamless integration with .NET framework


Separate implementation


Python interpreter in .NET CLI


Implements the same language


Same set of standard modules


Developed by Microsoft


Easy integration with C#, VB, etc..

Slide
16



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

PyPy


Python implemented in Python


For studying

Slide
17



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Example function

def gcd(a, b):


"greatest common divisor"


while a != 0:


a, b = b%a, a # parallel assignment


return b

Slide
18



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

Example class

class Stack:


"A well
-
known data structure" # doc string


def __init__(self): # constructor


self.items = []


def push(self, x):


self.items.append(x) # the sky is the limit


def pop(self):


x = self.items[
-
1] # what happens if it’s empty?


del self.items[
-
1]


return x


def empty(self):


return len(self.items) == 0

Slide
19



©2001, 2002 Guido
-
van
-
Rossum

2006 Sung
-
Jin Hong

References and plugs


References:


www.python.org
-

Python home site


documentation, downloads, community, PSF


www.pythonology.org
-

success stories


www.artima.com/intv
-

interview with GvR


www.zope.org
-

Zope community site


www.zope.com
-

Zope corporate site


Python Conferences (see www.python.org):


PyCon DC March 26
-
28 Washington, DC


on
-
line registration ends today ($200)


Python UK April 2
-
3 Oxford, England


EuroPython June 25
-
27 Charleroi, Belgium


Python11 at OSCON July 7
-
11 Portland, OR