Python 3000 (ACCU Conference / Oxford, UK / April 19, 2006) Guido van Rossum

Slides:



Advertisements
Similar presentations
Python 3000 and You Guido van Rossum EuroPython July 7, 2008.
Advertisements

Python 3000 (PyCon, 24-Feb-02007) Guido van Rossum
Python 3000 and You Guido van Rossum PyCon March 14, 2008.
Python Regrets OSCON, July 25, 2002
Optional Static Typing Guido van Rossum (with Paul Prescod, Greg Stein, and the types-SIG)
More about Ruby Maciej Mensfeld Presented by: Maciej Mensfeld More about Ruby dev.mensfeld.pl github.com/mensfeld.
Chapter 2.2 – More about Ruby Maciej Mensfeld Presented by: Maciej Mensfeld More about Ruby dev.mensfeld.pl github.com/mensfeld senior.
ThinkPython Ch. 10 CS104 Students o CS104 n Prof. Norman.
Bruce Beckles University of Cambridge Computing Service
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
A Crash Course Python. Python? Isn’t that a snake? Yes, but it is also a...
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
Introduction to Python
1 Fall 2008ACS-1903 for Loop Reading files String conversions Random class.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
While Loops and Do Loops. Suppose you wanted to repeat the same code over and over again? System.out.println(“text”); System.out.println(“text”); System.out.println(“text”);
Introduction to Python (for C++ programmers). Background Information History – created in December 1989 by Guido van Rossum Interpreted Dynamically-typed.
A Moderately Directed Rant.  It’s very likely that you’ve been writing totally incorrect code without realizing it  Once you do realize it, it’s usually.
Game Programming © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line L.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
CIS Computer Programming Logic
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
1 Python CIS*2450 Advanced Programming Concepts Material for this lecture was developed by Dr. D. Calvert.
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
Guide to Programming with Python Chapter Seven (Part 1) Files and Exceptions: The Trivia Challenge Game.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Python Programming Chapter 6: Iteration Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Control Structures. Important Semantic Difference In all of these loops we are going to discuss, the braces are ALWAYS REQUIRED. Even if your loop/block.
CSE 143 Lecture 11 Maps Grammars slides created by Alyssa Harding
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Java 5 Part 1 CSE301 University of Sunderland Harry Erwin, PhD.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Eclipse debugger.
Getting Started with Python: Constructs and Pitfalls Sean Deitz Advanced Programming Seminar September 13, 2013.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Python Overview  Last week Python 3000 was released  Python 3000 == Python 3.0 == Py3k  Designed to break backwards compatibility with the 2.x.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Jim Havrilla. Invoking Python Just type “python –m script.py [arg]” or “python –c command [arg]” To exit, quit() or Control-D is used To just use the.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Python Let’s get started!.
I NTRODUCTION TO PYTHON - GETTING STARTED ( CONT )
Chapter 7 Continued Arrays & Strings. Arrays of Structures Arrays can contain structures as well as simple data types. Let’s look at an example of this,
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Quiz 4 Topics Aid sheet is supplied with quiz. Functions, loops, conditionals, lists – STILL. New topics: –Default and Keyword Arguments. –Sets. –Strings.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Discover Python 3 Slavek Kabrda Presented by
Python 3000.
Fundamentals of Programming I Overview of Programming
Taken from notes by Dr. Neil Moore & Dr. Debby Keen
ECS10 10/10
LING 388: Computers and Language
Topics Introduction to File Input and Output
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
CISC101 Reminders Slides have changed from those posted last night…
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Python programming exercise
CISC101 Reminders All assignments are now posted.
CISC101 Reminders Assignment 2 due today.
Topics Introduction to File Input and Output
CISC101 Reminders Assignment 3 due today.
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Presentation transcript:

Python 3000 (ACCU Conference / Oxford, UK / April 19, 2006) Guido van Rossum

April 19, 2006(c) 2006 Python Software Foundation2 Talk Overview Python 3000 Philosophy Python 3000 Process Python 3000 Features Questions

April 19, 2006(c) 2006 Python Software Foundation3 Python 3000 Philosophy Dont design a whole new language! Fix early design bugs (many from !) Allow incompatible changes; within reason Get rid of deprecated features –especially when that creates incompatibilities e.g. int division Consider whats the best feature going forward NB: Python 3000 = Python 3.0 = Py3k

April 19, 2006(c) 2006 Python Software Foundation4 Python 3000 Process Without some amount of process were lost! Too many proposals competing for time Dont want to become the next Perl 6 Examples of process/meta-questions: –when should we aim to release Python 3000? –how long will we maintain 2.x and 3.x side by side? –exactly how incompatible is Py3k allowed to be? –how will we migrate 2.x code to 3.x? –is anything competely off the table? –how to merge 3.0 features back into 2.x?

April 19, 2006(c) 2006 Python Software Foundation5 Release Schedule First alpha: not before next year Final release: probably a year after that May release 3.1, 3.2 relatively soon after Python 2.x and 3.x to be developed in parallel –Dont want users holding breath waiting for 3.0 –Provide good support while 3.0 matures –2.6: certainly (expected before 3.0) –2.7: likely; may contain some 3.0 backports –2.9 is as far as well go (running out of digits :-)

April 19, 2006(c) 2006 Python Software Foundation6 How Incompatible Can It Be? New keywords allowed dict.keys(), range(), zip() wont return lists –killing dict.iterkeys(), xrange(), itertools.izip() All strings Unicode; mutable bytes data type Binary file I/O redesign Drop <> as alias for != But not (for example): –dict.keys instead of dict.keys() –change meaning of else-clause on for/while –change operator priorities

April 19, 2006(c) 2006 Python Software Foundation7 How to Migrate Code? Cant do perfect mechanical translation –Many proposed changes are semantic, not syntactic –For example, in f(x.keys()) is x a dict? does f() expect its argument to be a list? –Answers may be guessed by e.g. pychecker but cant always be decided with certainty Most likely approach: –use pychecker-like tool to do an 80+% job –create an instrumented version of Python 2.x that warns about doomed code (e.g. d.keys().sort())

April 19, 2006(c) 2006 Python Software Foundation8 Five Is Right Out From PEP 3099 (and from The Holy Grail :-) Python 3000 will not: –have programmable syntax / macros / etc. –add syntax for parallel iteration (use zip()) –change hash, keys etc. to attributes –change iterating over a dict to yield key-value pairs In general we shouldnt: –change the look and feel of the language too much –make gratuitous or confusing changes –add radical new features (can always do that later)

April 19, 2006(c) 2006 Python Software Foundation9 Python 3000 Features Scratching just the surface Few things have been decided for certain Read PEP 3100 for a much larger laundry list –see python.org/dev/peps/ Follow the list: –sign up at python.org/mailman/listinfo Read my blog: artima.com/weblogs/

April 19, 2006(c) 2006 Python Software Foundation10 Basic Cleanup Kill classic classes Exceptions must derive from BaseException int/int will return a float Remove last differences between int and long Absolute import by default Kill sys.exc_type and friends (exc_info() stays) Kill dict.has_key(), file.xreadlines() Kill apply(), input(), buffer(), coerce(), … Kill ancient library modules

April 19, 2006(c) 2006 Python Software Foundation11 Minor Syntactic Changes exec becomes a function again kill `x` in favor of repr(x) change except clause syntax to except E1, E2, E3 as err: –this avoids the bug in except E1, E2: # meant except (E1, E2) [f(x) for x in S] becomes syntactic sugar for list(f(x) for x in S) # a generator expression –subtle changes in need for parentheses –x no longer leaks into surrounding scope kill raise E, arg in favor of raise E(arg)

April 19, 2006(c) 2006 Python Software Foundation12 range() Becomes xrange() range() will no longer return a list –It wont return an iterator either It will return an iterator well –thats just what xrange() is, anyway xrange() doesnt support long values yet –well fix that :-) Think of this as similar to dict views (see later)

April 19, 2006(c) 2006 Python Software Foundation13 zip() Becomes izip() Thats what it shouldve been all along But zip() was introduced in Python 2.0 –which didnt have iterators Theres no need for zip() to be a view etc. –99% use case is parallel iteration –similar to enumerate()

April 19, 2006(c) 2006 Python Software Foundation14 lambda Lives! Last year, I said I wanted lambda to die –but I was open to a better version We still dont have a better version –despite a year of trying So lambda lives! –lets stop wasting time looking for alternatives –its as good as it gets; trust me!

April 19, 2006(c) 2006 Python Software Foundation15 String Types Reform bytes and str instead of str and unicode –bytes is a mutable array of int (in range(256)) –encode/decode API? bytes(s, "Latin-1")? –bytes have some str-ish methods (e.g. b1.find(b2)) –but not others (e.g. not b.upper()) All data is either binary or text –all text data is represented as Unicode –conversions happen at I/O time Different APIs for binary and text streams –how to establish file encoding? (Platform decides)

April 19, 2006(c) 2006 Python Software Foundation16 New Standard I/O Stack C stdio has too many problems –dont know how many bytes are buffered –write after read unsafe (libc doesnt promise safety) –Windows text mode nightmares –Universal newlines hacked in (for input only) bytes/str gives an opportunity to fix all this –learn from Java streams API –stackable components: buffering, encoding, … –see sandbox/sio/sio.py for an early prototype

April 19, 2006(c) 2006 Python Software Foundation17 Print Becomes a Function print x, y, x becomes print(x, y, z) print >>f, x, y, z becomes print(x, y, z, file=f) Alternative(s?) to skip the space/newline –printf(format, x, y, z)? –printraw(x, y, z)? or print(x, y, z, raw=True)? Why not f.print(x, y, z)? –because that requires support in every file type Why change at all? –print-as-statement is a barrier to evolution of your program and of the language (see link in PEP 3100)

April 19, 2006(c) 2006 Python Software Foundation18 Dict Views Instead of Lists dict.keys() currently returns a list –thats expensive if dict is large so we introduced dict.iterkeys() –but now the API becomes too large Proposal (affects dicts only!): –dict.keys() and dict.items() will return a set view –dict.values() will return a bag (multiset) view –a view is a wrapper object –can delete from but not add to a view modifies the dict accordingly –iterating over a view creates a new iterator object

April 19, 2006(c) 2006 Python Software Foundation19 Drop Default Inequalities The default implementations of, >= arent very useful (compare by address!) Let these raise TypeError instead NB: the default implementations of ==, != should remain (comparing identity is useful!)

April 19, 2006(c) 2006 Python Software Foundation20 Generic/Overloaded Functions A single callable with multiple implementations Contains a registry indexed by call signature –i.e. tuple(type(X) for X in args) –this maps to an implementation for those types –dispatches on type of all arguments at once! –(solvable) complications: inheritance Use a decorator for registration calls This can replace adaptation too! –make the protocol object an overloaded function –spell adapt(X, P) / P.adapt(X) as P(X)

Got Questions?