We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byGrace Craig
Modified over 3 years ago
State of the Python Union OSCON Portland, Oregon July 29, 2004 Guido van Rossum Elemental Security, Inc. email@example.com firstname.lastname@example.org
July 29, 2004© 2004 Guido van Rossum 2
July 29, 2004© 2004 Guido van Rossum 3 Keynote Overview PSF Grants Release status Python 2.4: –Generator expressions –Decorators –Other news Beyond Python 2.4 Miscellaneous remarks Cute demos Question time
July 29, 2004© 2004 Guido van Rossum 4
July 29, 2004© 2004 Guido van Rossum 5 PSF Grants Grants for projects related to: –the further development of Python –Python-related technology –educational resources Proposals to be submitted by October 1, 2004 –proposals granted by November 1, 2004 –work to be completed by October 30, 2005 Up to $40,000 available in total See python.org for details and how to submit
July 29, 2004© 2004 Guido van Rossum 6
July 29, 2004© 2004 Guido van Rossum 7 Release Status Python 2.2 is resting ("pining for the fjords") Python 2.3 is actively maintained –2.3.4 came out in May –2.3.5 planned later this year –Anthony Baxter is release manager I am out of the loop! Python 2.4 alpha 2 to be released next week –2.4 final release expected Q4 2004 –Anthony Baxter is release manager I am mostly out of the loop!
July 29, 2004© 2004 Guido van Rossum 8
July 29, 2004© 2004 Guido van Rossum 9 Generator Expressions Consider: print sum(x**2 for x in range(10)) Compare: –total = 0 for x in range(10): total += x**2 print total Factor out summing algorithm for reuse Concentrate on providing input without distractions Easily switch between different data processors –"accumulator functions" –"iterator algebra" a.k.a. pipelining
July 29, 2004© 2004 Guido van Rossum 10 Why Generator Expressions? Notation is immediately understandable Avoids building up a list of intermediate results –This is especially important if: intermediate results are large; or there are many intermediate results; or the source is an infinite sequence –e.g. from itertools: count(), cycle(), repeat() the consumer doesn't consume all results an interactive user is waiting for the initial results List comprehensions are a special case: –[f(x) for x...] is syntactic sugar for list(f(x) for x...) (in Python 2.4 there are some corner cases with different semantics; these will be fixed in 3.0) won't go away
July 29, 2004© 2004 Guido van Rossum 11 The Generator Expression Debate Someone noticed an "implementation flaw": –a =  for f in [math.sin, math.cos, math.tan]: a.append(f(x) for x in range(10)) –for iterator in a: for x in iterator: print x, print –Prints math.tan(x) series three times! (f is bound late) Should we try to fix this? (If so, how?) NO! Genexps are for immediate consumption –fix the docs / tutorials / examples –delayed use would be expert/advanced use anyway working solutions are quite bearable
July 29, 2004© 2004 Guido van Rossum 12
July 29, 2004© 2004 Guido van Rossum 13 Decorators Consider (introduced in python 2.2): –class C: def func(args):...100 lines of body text... func = staticmethod(func) Problem with this syntax: –programmer may forget to add the staticmethod() call –reader may miss the staticmethod() call Proposed solution: –class C: ***DECORATOR SYNTAX*** func(args): body
July 29, 2004© 2004 Guido van Rossum 14 What Is a Decorator? A decorator is a meta-function: –input is a callable or descriptor (implements __get__) –output is a callable or descriptor –examples: classmethod, staticmethod, (property) Other use cases: –metadata (e.g. author, version, deprecation) –processing rules (e.g. SPARK's grammar rules) –support for external language bindings (ObjC, C#) –framework annotations (e.g. PIKE) Ideally, decorators should be chainable
July 29, 2004© 2004 Guido van Rossum 15 Decorator Syntax Candidates Java 1.5: –@decorator and/or @decorator(key=value,...) C#: –[decorator, decorator,...] Other proposals from Python developers: –[decorator, decorator,...] in various other positions –*[decorators]* – –[as decorators] –other keywords or symbols
July 29, 2004© 2004 Guido van Rossum 16 Decorator (Ab)uses def funcattrs(**kwds): def helper(func): func.__dict__.update(kwds) return func return helper Example with Java 1.5-derived syntax: –@funcattrs(grammar="blah", author="GvR") def blah(args): body Example with C#-derived syntax: –[funcattrs(grammar="blah", author="GvR")] def blah(args): body
July 29, 2004© 2004 Guido van Rossum 17 Which Decorator Syntax? All styles have their disadvantages: –@decorator looks unpythonic (?) –[deco, deco,...] prefix ambiguous syntax and doesn't work in interactive interpreter –[deco, deco,...] after arguments hides the decorators too much is awkward for long decorators –Other proposals look arbitrary (even 'as') In 2.4a2, we'll implement @decorator –if everybody hates it, we'll revisit in a3 or b1
July 29, 2004© 2004 Guido van Rossum 18
July 29, 2004© 2004 Guido van Rossum 19 What Else is New in 2.4? Faster (e.g. tklife.py gains ~20% speed-up) New built-in set types: set and frozenset Unifying int and long: now always the same results –except repr() still returns an 'L' suffix for longs New builtins: sorted(), reversed() Keyword arguments to list.sort(): cmp, key, reverse eval() takes arbitrary mapping for locals (only) None is a constant (assigning to it is a syntax error) Decimal floating point data type (module decimal) Email parser rewritten from scratch CJKCodecs integrated (East-Asian codecs) New module cookielib (client-side cookie handling) Windows distribution now built using MSVC++ 7.1
July 29, 2004© 2004 Guido van Rossum 20
July 29, 2004© 2004 Guido van Rossum 21 Beyond Python 2.4 Python 2.5.........2.9: –gradual improvements –new library modules/packages –backwards-compatible changes –implement more existing PEPs –performance work –implementation internals work (e.g. AST branch) –experiment with features proposed for Python 3.0 There will not be a Python 2.10 –but 2.5... 2.9 may be released in parallel with 3.0
July 29, 2004© 2004 Guido van Rossum 22
July 29, 2004© 2004 Guido van Rossum 23 Python 3.0 (a.k.a. Python 3000) I had a Python 3.0 slide, but it's all day-dreaming 3.0 is my excuse for putting off thorny issues Has been "about 3 years away" since 2000 :-) I need to retire to be able to work on this Python 3.0 : 2.x isn't anything like Perl 6.0 : 5.x But it will be incompatible
July 29, 2004© 2004 Guido van Rossum 24
July 29, 2004© 2004 Guido van Rossum 25 Miscellaneous Remarks The sincerest form of flattery is imitation –Python borrows from many other languages –Now Ruby, Groovy, Prothon borrow from Python Python runs on Nokia Series 60 phones –Public release not yet certain –Would open up Nokia platform to more developers Write your secure programs in Python –1 security defect per 1000 lines across languages –But in Python it takes fewer lines :-) Community issues –Why is there still no Python equivalent of CPAN? –There are too many projects doing X; how to choose?
July 29, 2004© 2004 Guido van Rossum 26
July 29, 2004© 2004 Guido van Rossum 27 Cute Demos ElementClass –Simple way to describe (some) XML documents –Get attributes and subelements as Python attributes –Parses string or stream into tree in memory –Renders to string or stream –Not (yet) released, developed for Elemental Security Conway's Game of Life / Damian's cellular automata
July 29, 2004© 2004 Guido van Rossum 28
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Lilian Blot PART V: FUNCTIONS Core elements Autumn 2013 TPOP 1.
Lilian Blot CORE ELEMENTS SELECTION & FUNCTIONS Lecture 3 Autumn 2014 TPOP 1.
CS1022 Computer Programming & Principles
Chapter 6 Writing a Program
Slide 5-1 Copyright © 2003 Pearson Education, Inc. Figure: Computer Science an overview EDITION 7 J. Glenn Brookshear.
Januar 2005 S M T O T F L
The State of the Python Union BDFL PyCon – March 24, 2005 Guido van Rossum Elemental Security, Inc.
McDonald’s calendar 2009.
Simplifications of Context-Free Grammars
Programming Language Concepts
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 4 Beginning Functions 4/5/09 Python Mini-Course: Day 1 - Lesson 4 1.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Chapter 1 The Study of Body Function Image PowerPoint
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
31242/32549 Advanced Internet Programming Advanced Java Programming
Why I Invented Python EuroPython – June 27, 2005 Guido van Rossum Elemental Security, Inc.
© 2017 SlidePlayer.com Inc. All rights reserved.