SlideShare a Scribd company logo
Python 3000 (PyCon, 24-Feb-02007)‏ Guido van Rossum [email_address] [email_address]
What Is Python 3000? The next  major  Python release To be released as Python 3.0 The first one in a long time to be  incompatible But not completely different or unusual Concept first formed around 2000 Py3k nickname was a play on Windows 2000 Goal: to correct my early design mistakes Those that would require incompatibility to fix Reduce cognitive load for first-time learners Work and thinking started for real last year
Activity Since Last Year Lots of design discussions (too many, if you ask me :-)‏ Some PEPs were written (but not enough…)‏ Lots of code was written (just the right amount!)‏ (but we're not done yet!!)‏
Python 3.0 Timeline PEPs to be completed: April 2007 3.0a1: June 2007 3.0 final: June 2008 For comparison, the 2.6 timeline: 2.6a1: December 2007 2.6 final: April 2008 There will also be a 2.7 timeline
Rest of the Talk Highlight some of the most visible changes print function, dict views, comparisons, unicode, … How to convert 2.x to 3.0 code Notational convention: * = incompletely implemented ** = not yet implemented
No More Classic Classes In 2.2 … 2.9: class C: # classic class (0.1 … 2.1)‏ class C(object): # new-style class (old now :-)‏ In 3.0: both are new-style classes (just say "classes")‏ Differences are subtle, few of you will notice
Print is a Function print x, y -> print(x, y)‏ print x, -> print(x, end=" ")‏ print >>f, x -> print(x, file=f)‏ Automatic translation is 98% correct Fails for cases involving softspace cleverness: print "x\n", "y" doesn 't insert a space before y print("x\n", "y") does ditto for print "x\t", "y"
Dictionary Views Inspired by Java Collections Framework Remove .iterkeys(), .iteritems(), .itervalues()‏ Change .keys(), .items(), .values()‏ These return a  dict view Not an iterator A lightweight object that can be iterated repeatedly .keys(), .items() have set semantics .values() has "collection" semantics supports iteration and not much else
Default Comparison Changed Default ==, != compare object identity (this is unchanged)‏ Default <, <=, >, >= raise TypeError Example: [1, 2, &quot;&quot;].sort() raises TypeError Rationale: 2.x default ordering is bogus depends on type names depends on addresses
**Unicode Strings Java-like model: strings (the str type) are always Unicode separate bytes type must explicitly specify encoding to go between these Open issues: implementation fixed-width characters for O(1) indexing maybe 3 internal widths: 1, 2, 4 byte characters C API issues (many C APIs use C char* pointers)‏ optimize slicing and concatenation??? lots of issues, supporters, detractors
The Bytes Type A  mutable  sequence of small ints (0…255)‏ b[0] is an int; b[:1] is a new bytes object Implemented efficiently as unsigned char[] Has some list-like methods, e.g. .extend()‏ Has some string-like methods, e.g. .find()‏ But none that depend on locale bytes literals: b&quot;ascii or \xDD or \012&quot; bytes has .decode() method returning a string str has a .encode() method returning bytes
**New I/O Library Stackable components (inspired by Java, Perl)‏ Lowest level: unbuffered byte I/O platform-specific; don't use C stdio Add buffering Add unicode encoding/decoding encoding explicitly specified or somehow guessed Add CRLF/LF mapping Compatible API open(filename) returns a buffered text file read() and readline() return strings open(filename, &quot;b&quot;) returns a buffered binary file read() returns bytes; can't use readline()‏
Int/Long Unification There is only one built-in integer type Its name is int Its implementation is like long in Python 2.x C API is a bit murky Performance could use a boost
Int Division Returns a Float Always! Same effect in 2.x with from __future__ import division Use // for int division Use -Q option to Python 2.x to find old usage
**Raise and Except Changes All exceptions must derive from BaseException Exceptions have __traceback__ attribute Must use raise E(arg) instead of raise E, arg Can still use raise E and raise without args Use raise E(arg).with_traceback(tb)‏ instead of raise E, arg, tb Use &quot;except E as v:&quot; instead of &quot;except E, v:&quot; Variable v is deleted at end of except block!!!
Signature Annotations NOT  type declarations! Example: def foo(x: &quot;whatever&quot;, y: list(range(3))) -> 42*2: … Argument syntax is (roughly): NAME [':' expr] ['=' expr] Both expressions are evaluated at 'def' time foo.func_annotations is: {'a': &quot;whatever&quot;, 'b': [0, 1, 2], &quot;return&quot;: 84} NO other use is made of these annotations
Keyword-Only Parameters Example def: def foo(a, b=1, *, c=42, d): … Example call: foo(1, 2, d=3)‏ Cannot  use: foo(1, 2, 3)  # raises TypeError
Set Literals {1, 2, 3} is the same as set([1, 2, 3])‏ No empty set literal; use set()‏ No frozenset literal; use frozenset({…})‏ **Set comprehensions: { f ( x ) for  x  in  S  if  P ( x )} same as set( f ( x ) for  x  in  S  if  P ( x ))‏
Absolute Import Same effect in 2.5 with from __future__ import absolute_import Within a package &quot;import foo&quot; does  NOT  search the package path, only sys.path Use &quot;from . import foo&quot; for relative import Or use from <full-package-name> import foo
**String Formatting Examples (see PEP 3101 for more): &quot;See {0}, {1} and {foo}&quot;.format(&quot;A&quot;, &quot;B&quot;, foo=&quot;C&quot;)‏ &quot;See A, B and C&quot; &quot;my name is {0} :-{{}}&quot;.format(&quot;Fred&quot;)‏ &quot;my name is Fred :-{}&quot; &quot;File name {0.foo}&quot;.format(open(&quot;foo.txt&quot;))‏ File name foo.txt &quot;Name is {0[name]}&quot;.format({&quot;name&quot;: &quot;Fred&quot;})‏ &quot;Name is Fred&quot; Shoe size {0:8}&quot;.format(42)‏ &quot;Shoe size  42&quot;
**Nonlocal Statement def outer():   x = 42   def inner():   nonlocal x # <---- new   print(x)   x += 1   return inner Doesn't work today; x becomes a local in inner Different keywords proposed: nonlocal, global, outer, … (see PEP 3104)‏
**Abstract Base Classes? Still highly speculative (no PEP yet)‏ wiki.python.org/moin/AbstractBaseClasses Introduce a standard abstract class hierarchy for type categories like file, container, sequence, iterable etc. Standard types to use these as base classes User-defined types  may  use these When used, can help distinguishing e.g. sequence from mapping, or file-like behavior, or &quot;stringiness&quot;, or &quot;numericity&quot;, etc.
**Switch/Case Statement??? Highly speculative; see PEP 3103 switch EXPR:   case EXPR:   SUITE   case EXPR: # or case in EXPRLIST:   SUITE   …   [else:   SUITE] Problem: when to compile EXPR? Would prefer precompilation for faster execution But this would introduce unusual semantics
Miscellaneous Changes exec becomes a function again range() becomes xrange()‏ input() becomes raw_input()‏ zip() returns an iterator Moved intern() into sys module Renamed __nonzero__ to __bool__ 'as' and 'with' are keywords And more, planned and implemented
Miscellaneous Removals classic classes: new-style classes default backticks: use repr()‏ Removed <>: use != apply(): use func(*args)‏ coerce(), __coerce__: not needed dict.has_key(): use key in dict 'softspace' attribute on file objects
**Library Reform Not my priority Others are interested, but effort seems stalled Need help! May happen after 3.0a1 is released
*C API Changes Too early to tell what will happen 3rd party extension authors want to know For now, these simple rules: Adding APIs is okay (of course)‏ Deleting APIs is okay Changing APIs incompatibly is NOT OKAY
Converting 2.x Code to 3.0 Generic conversion tool exists sandbox/2to3 accurate source-to-source transformation parse tree decorated with whitespace & comments New conversions are easily added create a class from boilerplate add a class variable PATTERN to match nodes add a method transform() to transform one node Separately, Python 2.6 will help can warn about out-of-date usages can provide forward-compatible alternatives
Examples of What It Can Do apply(fun, args, kwds) -> fun(*args, **kwds)‏ d.iterkeys() -> d.keys()‏ exec a in b, c -> exec(a, b, c)‏ print >>sys.stderr, x, ->   print(x, end=&quot; &quot;, file=sys.stderr)‏ except E, v: -> except E as v: d.has_key(k) -> k in d intern(s) -> sys.intern(s)‏ a <> b -> a != b; `x` -> repr(x); int -> long automatically adds parentheses where needed
Examples of What It  Can't  Do detect whether d is a dict (in d.iterkeys())‏ detect whether you use d.keys() as a list later turn int()/int() into int()//int()‏ fix code that depends on int() < str()‏ remove redundant code fix custom classes emulating dictionaries fix string exceptions, non-Exception exceptions in general: limited to syntactic conversions can't follow control flow, doesn't do type inference
What You Can Do Today Don't worry about stuff that can be automated Don't try to write source-level compatible code Use Python 2.6 when it comes out Write unit tests with maximal coverage Use keys = sorted(d.iterkeys())‏ Use list(d.iterkeys()) when you really need a list Derive all exceptions from Exception Derive all classes from object Don't rely on subtle print/softspace  semantics use print line.rstrip(&quot;\n&quot;) instead of print line, Use // for int division
Questions
Ad

Recommended

F# 101
F# 101
Chris Alcock
 
Functional Programming in F#
Functional Programming in F#
Dmitri Nesteruk
 
Get Functional on the CLR: Intro to Functional Programming with F#
Get Functional on the CLR: Intro to Functional Programming with F#
David Alpert
 
Rx workshop
Rx workshop
Ryan Riley
 
Docase notation for Haskell
Docase notation for Haskell
Tomas Petricek
 
Teaching F#
Teaching F#
Tomas Petricek
 
Reasonable Code With Fsharp
Reasonable Code With Fsharp
Michael Falanga
 
Reactive fsharp
Reactive fsharp
Skills Matter
 
Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015
Phillip Trelford
 
Pipeline oriented programming
Pipeline oriented programming
Scott Wlaschin
 
仕事で使うF#
仕事で使うF#
bleis tift
 
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
climatewarrior
 
C Programming Homework Help
C Programming Homework Help
Programming Homework Help
 
Ch8a
Ch8a
kinnarshah8888
 
Python unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabus
DhivyaSubramaniyam
 
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - Kalamassery
SHAMJITH KM
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Philip Schwarz
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
Eelco Visser
 
Computer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
Computer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
03. Operators Expressions and statements
03. Operators Expressions and statements
Intro C# Book
 
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Philip Schwarz
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions in C++ 3
Ali Aminian
 
Functional programming in C++
Functional programming in C++
Alexandru Bolboaca
 
Type header file in c++ and its function
Type header file in c++ and its function
Frankie Jones
 
Os Vanrossum
Os Vanrossum
oscon2007
 
Python Evolution
Python Evolution
Quintagroup
 

More Related Content

What's hot (20)

Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015
Phillip Trelford
 
Pipeline oriented programming
Pipeline oriented programming
Scott Wlaschin
 
仕事で使うF#
仕事で使うF#
bleis tift
 
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
climatewarrior
 
C Programming Homework Help
C Programming Homework Help
Programming Homework Help
 
Ch8a
Ch8a
kinnarshah8888
 
Python unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabus
DhivyaSubramaniyam
 
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - Kalamassery
SHAMJITH KM
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Philip Schwarz
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
Eelco Visser
 
Computer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
Computer Science Assignment Help
Computer Science Assignment Help
Programming Homework Help
 
03. Operators Expressions and statements
03. Operators Expressions and statements
Intro C# Book
 
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Philip Schwarz
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions in C++ 3
Ali Aminian
 
Functional programming in C++
Functional programming in C++
Alexandru Bolboaca
 
Type header file in c++ and its function
Type header file in c++ and its function
Frankie Jones
 
Beyond lists - Copenhagen 2015
Beyond lists - Copenhagen 2015
Phillip Trelford
 
Pipeline oriented programming
Pipeline oriented programming
Scott Wlaschin
 
仕事で使うF#
仕事で使うF#
bleis tift
 
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
climatewarrior
 
Python unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabus
DhivyaSubramaniyam
 
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - Kalamassery
SHAMJITH KM
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Philip Schwarz
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
Eelco Visser
 
03. Operators Expressions and statements
03. Operators Expressions and statements
Intro C# Book
 
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Philip Schwarz
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions in C++ 3
Ali Aminian
 
Type header file in c++ and its function
Type header file in c++ and its function
Frankie Jones
 

Similar to Python 3000 (20)

Os Vanrossum
Os Vanrossum
oscon2007
 
Python Evolution
Python Evolution
Quintagroup
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
gekiaruj
 
python within 50 page .ppt
python within 50 page .ppt
sushil155005
 
python language programming presentation
python language programming presentation
lbisht2
 
Python Workshop. LUG Maniapl
Python Workshop. LUG Maniapl
Ankur Shrivastava
 
Python Presentation
Python Presentation
Narendra Sisodiya
 
Programming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
 
Intro to Python
Intro to Python
OSU Open Source Lab
 
Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)
Mohan Arumugam
 
A tour of Python
A tour of Python
Aleksandar Veselinovic
 
An overview of Python 2.7
An overview of Python 2.7
decoupled
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
Kevlin Henney
 
Introduction to Python
Introduction to Python
UC San Diego
 
Pydiomatic
Pydiomatic
rik0
 
Python idiomatico
Python idiomatico
PyCon Italia
 
Moving to Python 3
Moving to Python 3
Nick Efford
 
An Introduction : Python
An Introduction : Python
Raghu Kumar
 
Introduction to Python For Diploma Students
Introduction to Python For Diploma Students
SanjaySampat1
 
Python 3000
Python 3000
Bob Chao
 
Os Vanrossum
Os Vanrossum
oscon2007
 
Python Evolution
Python Evolution
Quintagroup
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
gekiaruj
 
python within 50 page .ppt
python within 50 page .ppt
sushil155005
 
python language programming presentation
python language programming presentation
lbisht2
 
Python Workshop. LUG Maniapl
Python Workshop. LUG Maniapl
Ankur Shrivastava
 
Programming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
 
Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)
Mohan Arumugam
 
An overview of Python 2.7
An overview of Python 2.7
decoupled
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
Kevlin Henney
 
Introduction to Python
Introduction to Python
UC San Diego
 
Pydiomatic
Pydiomatic
rik0
 
Moving to Python 3
Moving to Python 3
Nick Efford
 
An Introduction : Python
An Introduction : Python
Raghu Kumar
 
Introduction to Python For Diploma Students
Introduction to Python For Diploma Students
SanjaySampat1
 
Python 3000
Python 3000
Bob Chao
 
Ad

More from Alexandro Colorado (20)

Bitcuners revolucion blockchain
Bitcuners revolucion blockchain
Alexandro Colorado
 
Presentacion Krita
Presentacion Krita
Alexandro Colorado
 
Bitcuners porque bitcoins
Bitcuners porque bitcoins
Alexandro Colorado
 
ChamiloCon Enseñando con Tecnología
ChamiloCon Enseñando con Tecnología
Alexandro Colorado
 
Curso de desarrollo web para principiantes
Curso de desarrollo web para principiantes
Alexandro Colorado
 
ChamiloCon: Recursos de Software Libre
ChamiloCon: Recursos de Software Libre
Alexandro Colorado
 
Krita - Tu tambien puedes pintar un arbol Feliz
Krita - Tu tambien puedes pintar un arbol Feliz
Alexandro Colorado
 
Gobernancia y particionacion en comunidades de Software Libre v2
Gobernancia y particionacion en comunidades de Software Libre v2
Alexandro Colorado
 
gcloud
gcloud
Alexandro Colorado
 
Blender - FLISOL Cancun 2014
Blender - FLISOL Cancun 2014
Alexandro Colorado
 
The Hitchhicker's Guide to Opensource
The Hitchhicker's Guide to Opensource
Alexandro Colorado
 
OpenERP: El ecosistema de negocios
OpenERP: El ecosistema de negocios
Alexandro Colorado
 
Aprendiendo GnuPG
Aprendiendo GnuPG
Alexandro Colorado
 
Catalogo decursos
Catalogo decursos
Alexandro Colorado
 
Practicas virtuales v2.2
Practicas virtuales v2.2
Alexandro Colorado
 
Introducción al curso de Extensiones de OpenOffice
Introducción al curso de Extensiones de OpenOffice
Alexandro Colorado
 
Comunidades software libre
Comunidades software libre
Alexandro Colorado
 
Practicas virtuales v2
Practicas virtuales v2
Alexandro Colorado
 
Practicas virtuales
Practicas virtuales
Alexandro Colorado
 
Economia digital
Economia digital
Alexandro Colorado
 
Bitcuners revolucion blockchain
Bitcuners revolucion blockchain
Alexandro Colorado
 
ChamiloCon Enseñando con Tecnología
ChamiloCon Enseñando con Tecnología
Alexandro Colorado
 
Curso de desarrollo web para principiantes
Curso de desarrollo web para principiantes
Alexandro Colorado
 
ChamiloCon: Recursos de Software Libre
ChamiloCon: Recursos de Software Libre
Alexandro Colorado
 
Krita - Tu tambien puedes pintar un arbol Feliz
Krita - Tu tambien puedes pintar un arbol Feliz
Alexandro Colorado
 
Gobernancia y particionacion en comunidades de Software Libre v2
Gobernancia y particionacion en comunidades de Software Libre v2
Alexandro Colorado
 
The Hitchhicker's Guide to Opensource
The Hitchhicker's Guide to Opensource
Alexandro Colorado
 
OpenERP: El ecosistema de negocios
OpenERP: El ecosistema de negocios
Alexandro Colorado
 
Introducción al curso de Extensiones de OpenOffice
Introducción al curso de Extensiones de OpenOffice
Alexandro Colorado
 
Ad

Recently uploaded (20)

FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 

Python 3000

  • 1. Python 3000 (PyCon, 24-Feb-02007)‏ Guido van Rossum [email_address] [email_address]
  • 2. What Is Python 3000? The next major Python release To be released as Python 3.0 The first one in a long time to be incompatible But not completely different or unusual Concept first formed around 2000 Py3k nickname was a play on Windows 2000 Goal: to correct my early design mistakes Those that would require incompatibility to fix Reduce cognitive load for first-time learners Work and thinking started for real last year
  • 3. Activity Since Last Year Lots of design discussions (too many, if you ask me :-)‏ Some PEPs were written (but not enough…)‏ Lots of code was written (just the right amount!)‏ (but we're not done yet!!)‏
  • 4. Python 3.0 Timeline PEPs to be completed: April 2007 3.0a1: June 2007 3.0 final: June 2008 For comparison, the 2.6 timeline: 2.6a1: December 2007 2.6 final: April 2008 There will also be a 2.7 timeline
  • 5. Rest of the Talk Highlight some of the most visible changes print function, dict views, comparisons, unicode, … How to convert 2.x to 3.0 code Notational convention: * = incompletely implemented ** = not yet implemented
  • 6. No More Classic Classes In 2.2 … 2.9: class C: # classic class (0.1 … 2.1)‏ class C(object): # new-style class (old now :-)‏ In 3.0: both are new-style classes (just say &quot;classes&quot;)‏ Differences are subtle, few of you will notice
  • 7. Print is a Function print x, y -> print(x, y)‏ print x, -> print(x, end=&quot; &quot;)‏ print >>f, x -> print(x, file=f)‏ Automatic translation is 98% correct Fails for cases involving softspace cleverness: print &quot;x\n&quot;, &quot;y&quot; doesn 't insert a space before y print(&quot;x\n&quot;, &quot;y&quot;) does ditto for print &quot;x\t&quot;, &quot;y&quot;
  • 8. Dictionary Views Inspired by Java Collections Framework Remove .iterkeys(), .iteritems(), .itervalues()‏ Change .keys(), .items(), .values()‏ These return a dict view Not an iterator A lightweight object that can be iterated repeatedly .keys(), .items() have set semantics .values() has &quot;collection&quot; semantics supports iteration and not much else
  • 9. Default Comparison Changed Default ==, != compare object identity (this is unchanged)‏ Default <, <=, >, >= raise TypeError Example: [1, 2, &quot;&quot;].sort() raises TypeError Rationale: 2.x default ordering is bogus depends on type names depends on addresses
  • 10. **Unicode Strings Java-like model: strings (the str type) are always Unicode separate bytes type must explicitly specify encoding to go between these Open issues: implementation fixed-width characters for O(1) indexing maybe 3 internal widths: 1, 2, 4 byte characters C API issues (many C APIs use C char* pointers)‏ optimize slicing and concatenation??? lots of issues, supporters, detractors
  • 11. The Bytes Type A mutable sequence of small ints (0…255)‏ b[0] is an int; b[:1] is a new bytes object Implemented efficiently as unsigned char[] Has some list-like methods, e.g. .extend()‏ Has some string-like methods, e.g. .find()‏ But none that depend on locale bytes literals: b&quot;ascii or \xDD or \012&quot; bytes has .decode() method returning a string str has a .encode() method returning bytes
  • 12. **New I/O Library Stackable components (inspired by Java, Perl)‏ Lowest level: unbuffered byte I/O platform-specific; don't use C stdio Add buffering Add unicode encoding/decoding encoding explicitly specified or somehow guessed Add CRLF/LF mapping Compatible API open(filename) returns a buffered text file read() and readline() return strings open(filename, &quot;b&quot;) returns a buffered binary file read() returns bytes; can't use readline()‏
  • 13. Int/Long Unification There is only one built-in integer type Its name is int Its implementation is like long in Python 2.x C API is a bit murky Performance could use a boost
  • 14. Int Division Returns a Float Always! Same effect in 2.x with from __future__ import division Use // for int division Use -Q option to Python 2.x to find old usage
  • 15. **Raise and Except Changes All exceptions must derive from BaseException Exceptions have __traceback__ attribute Must use raise E(arg) instead of raise E, arg Can still use raise E and raise without args Use raise E(arg).with_traceback(tb)‏ instead of raise E, arg, tb Use &quot;except E as v:&quot; instead of &quot;except E, v:&quot; Variable v is deleted at end of except block!!!
  • 16. Signature Annotations NOT type declarations! Example: def foo(x: &quot;whatever&quot;, y: list(range(3))) -> 42*2: … Argument syntax is (roughly): NAME [':' expr] ['=' expr] Both expressions are evaluated at 'def' time foo.func_annotations is: {'a': &quot;whatever&quot;, 'b': [0, 1, 2], &quot;return&quot;: 84} NO other use is made of these annotations
  • 17. Keyword-Only Parameters Example def: def foo(a, b=1, *, c=42, d): … Example call: foo(1, 2, d=3)‏ Cannot use: foo(1, 2, 3) # raises TypeError
  • 18. Set Literals {1, 2, 3} is the same as set([1, 2, 3])‏ No empty set literal; use set()‏ No frozenset literal; use frozenset({…})‏ **Set comprehensions: { f ( x ) for x in S if P ( x )} same as set( f ( x ) for x in S if P ( x ))‏
  • 19. Absolute Import Same effect in 2.5 with from __future__ import absolute_import Within a package &quot;import foo&quot; does NOT search the package path, only sys.path Use &quot;from . import foo&quot; for relative import Or use from <full-package-name> import foo
  • 20. **String Formatting Examples (see PEP 3101 for more): &quot;See {0}, {1} and {foo}&quot;.format(&quot;A&quot;, &quot;B&quot;, foo=&quot;C&quot;)‏ &quot;See A, B and C&quot; &quot;my name is {0} :-{{}}&quot;.format(&quot;Fred&quot;)‏ &quot;my name is Fred :-{}&quot; &quot;File name {0.foo}&quot;.format(open(&quot;foo.txt&quot;))‏ File name foo.txt &quot;Name is {0[name]}&quot;.format({&quot;name&quot;: &quot;Fred&quot;})‏ &quot;Name is Fred&quot; Shoe size {0:8}&quot;.format(42)‏ &quot;Shoe size 42&quot;
  • 21. **Nonlocal Statement def outer(): x = 42 def inner(): nonlocal x # <---- new print(x) x += 1 return inner Doesn't work today; x becomes a local in inner Different keywords proposed: nonlocal, global, outer, … (see PEP 3104)‏
  • 22. **Abstract Base Classes? Still highly speculative (no PEP yet)‏ wiki.python.org/moin/AbstractBaseClasses Introduce a standard abstract class hierarchy for type categories like file, container, sequence, iterable etc. Standard types to use these as base classes User-defined types may use these When used, can help distinguishing e.g. sequence from mapping, or file-like behavior, or &quot;stringiness&quot;, or &quot;numericity&quot;, etc.
  • 23. **Switch/Case Statement??? Highly speculative; see PEP 3103 switch EXPR: case EXPR: SUITE case EXPR: # or case in EXPRLIST: SUITE … [else: SUITE] Problem: when to compile EXPR? Would prefer precompilation for faster execution But this would introduce unusual semantics
  • 24. Miscellaneous Changes exec becomes a function again range() becomes xrange()‏ input() becomes raw_input()‏ zip() returns an iterator Moved intern() into sys module Renamed __nonzero__ to __bool__ 'as' and 'with' are keywords And more, planned and implemented
  • 25. Miscellaneous Removals classic classes: new-style classes default backticks: use repr()‏ Removed <>: use != apply(): use func(*args)‏ coerce(), __coerce__: not needed dict.has_key(): use key in dict 'softspace' attribute on file objects
  • 26. **Library Reform Not my priority Others are interested, but effort seems stalled Need help! May happen after 3.0a1 is released
  • 27. *C API Changes Too early to tell what will happen 3rd party extension authors want to know For now, these simple rules: Adding APIs is okay (of course)‏ Deleting APIs is okay Changing APIs incompatibly is NOT OKAY
  • 28. Converting 2.x Code to 3.0 Generic conversion tool exists sandbox/2to3 accurate source-to-source transformation parse tree decorated with whitespace & comments New conversions are easily added create a class from boilerplate add a class variable PATTERN to match nodes add a method transform() to transform one node Separately, Python 2.6 will help can warn about out-of-date usages can provide forward-compatible alternatives
  • 29. Examples of What It Can Do apply(fun, args, kwds) -> fun(*args, **kwds)‏ d.iterkeys() -> d.keys()‏ exec a in b, c -> exec(a, b, c)‏ print >>sys.stderr, x, -> print(x, end=&quot; &quot;, file=sys.stderr)‏ except E, v: -> except E as v: d.has_key(k) -> k in d intern(s) -> sys.intern(s)‏ a <> b -> a != b; `x` -> repr(x); int -> long automatically adds parentheses where needed
  • 30. Examples of What It Can't Do detect whether d is a dict (in d.iterkeys())‏ detect whether you use d.keys() as a list later turn int()/int() into int()//int()‏ fix code that depends on int() < str()‏ remove redundant code fix custom classes emulating dictionaries fix string exceptions, non-Exception exceptions in general: limited to syntactic conversions can't follow control flow, doesn't do type inference
  • 31. What You Can Do Today Don't worry about stuff that can be automated Don't try to write source-level compatible code Use Python 2.6 when it comes out Write unit tests with maximal coverage Use keys = sorted(d.iterkeys())‏ Use list(d.iterkeys()) when you really need a list Derive all exceptions from Exception Derive all classes from object Don't rely on subtle print/softspace semantics use print line.rstrip(&quot;\n&quot;) instead of print line, Use // for int division