lec10 A crash course in Python

lec10 A crash course in Python -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
http://www.cs.ucsd.edu/classes/fa06/cse130/lectures/lec10.txt Lecture 10: A crash course in Python ------------------------------------ Before we say goodbye to ML, I'd like to remind you, that learning to program in ML -- and in general, the functional style, will positively impact how you design and implement software systems. An example of this, is the use of a library called "MapReduce" inside Google. The MapReduce library allows Google programmers (not released yet) to compute complex functions over _all_ the pages indexed by Google. The library has exactly two functions: 1. map : ('a -> key * 'b) -> 'a list -> (key * 'b) list 2. reduce (a.k.a. "fold"): ('b * 'b -> 'b) -> 'b list -> 'b The actual implementation is in C++ and is done by a complex system that: 1. parallelizes across hundreds of machines 2. manages communication, synchronization, failures 3. all the programmer uses are map, reduce # Show slides, show parallelization Hundreds of different tasks programmed using map/reduce library in Google. OK. but, now, speaking of Google, is a language that is used heavily inside Google, and also in a variety of other tools, e.g. BitTorrent: PYTHON. Named after the British TV show: "Monty Python". So why are we studying Python ? The main reason is that its cool, as you will see very soon. But other than that, it fits right into our main goal of seeing what goes into the guts of a PL. .. ML PYTHON ----------------------------------------------------------------------------------- 1. PL Paradigm Functional Imperative,Object-Oriented 2. Basic Unit everything is a Value everything is an Object 3. Types Static/Compile-time Dynamic/Execution-Time "Duck-typing" 4. Vars,DataModel Env:var -> value Namespace: var -> object No mutation Objects are mutable 5. Scope Static/Lexical Static/Lexical 6. Functions Functions (are values) Functions (are objects) 7. Building Blocks Structures Classes + Modules Hiding w/ Signatures No hiding("convention") http://www.cs.ucsd.edu/classes/fa06/cse130/lectures/lec10.txt (1 of 11) [2/13/2008 5:10:42 PM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
http://www.cs.ucsd.edu/classes/fa06/cse130/lectures/lec10.txt ----------------------------------------------------------------------------------- Python has a very relaxed philosophy -- if something "can be done" then it is allowed. Combination of dynamic types + everything is an object makes for very flexible, very intuitive code. --> No static type system to "prohibit" operations --> At runtime, every "operation" is translated to a method call on the appropriate object. If the object supports the method, then the computation proceeds. Duck-typing: if it looks like a duck, quacks like a duck, then it is a duck! --> This loose, comfortable, free-style, philosophy is at the heart of python. --> This comes at a price. ML type discipline catches many bugs early
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/14/2008 for the course CSE 130 taught by Professor Jhala during the Fall '06 term at UCSD.

Page1 / 11

lec10 A crash course in Python -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online