Iteration, iteration, iteration

Video thumbnail (Frame 0) Video thumbnail (Frame 881) Video thumbnail (Frame 5971) Video thumbnail (Frame 6952) Video thumbnail (Frame 11387) Video thumbnail (Frame 12172) Video thumbnail (Frame 14069) Video thumbnail (Frame 27633) Video thumbnail (Frame 30020) Video thumbnail (Frame 30653)
Video in TIB AV-Portal: Iteration, iteration, iteration

Formal Metadata

Iteration, iteration, iteration
Title of Series
Part Number
Number of Parts
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
John Sutherland - Iteration, iteration, iteration There should be something for everyone in this whistle–stop tour of iteration in Python setting off from `for`–loops, and riding cross–country to multiplexing coroutines! See and hear the amazing sights and sounds of list comprehensions, and generators. Take in the amazing vistas from `itertools`, and be amazed at the magnificent `yield`! ----- We’ll take detours to higher–order functions, closures, and decorators. And cover the FP inspired builtins `map`, `filter`, and `reduce`, as well as the epitome of Pythonic programming, `enumerate`.
Goodness of fit Lecture/Conference Iteration
Slide rule Run time (program lifecycle phase) Link (knot theory) Divisor State of matter Multiplication sign Range (statistics) Real-time operating system Protein Theory Computer programming Revision control Mathematics Recursion Condition number Social class Electric generator Hazard (2005 film) Expression Bit Line (geometry) Loop (music) Computer animation Vector space Query language Personal digital assistant Calculation Factory (trading post) Self-organization Iteration Lipschitz-Stetigkeit Whiteboard Escape character
Functional (mathematics) System call Length Line (geometry) 1 (number) Front and back ends Goodness of fit Iteration Different (Kate Ryan album) Hypermedia Operator (mathematics) Program slicing Bus (computing) Integer Binary multiplier Thumbnail Form (programming) Electronic mailing list Operator (mathematics) Bit Sequence Word Computer animation Logic Factory (trading post) Numerical analysis Website Social class Iteration Natural language Cycle (graph theory) Communications protocol Reading (process) Reduction of order
Slide rule Boss Corporation Regulärer Ausdruck <Textverarbeitung> Electric generator Expression Fitness function Electronic mailing list Similarity (geometry) Database Electronic mailing list Portable communications device Permutation Dressing (medical) Computer animation Object (grammar) Data structure Electric generator
Group action System call Multiplication sign View (database) Execution unit Range (statistics) Entrainment (chronobiology) Semantics (computer science) Likelihood function Dimensional analysis Formal language Fluid statics Mathematics Object (grammar) Square number Convex set Information security Lambda calculus Social class Boss Corporation Electric generator Electronic mailing list Sound effect Bit Sequence Type theory Category of being Message passing Process (computing) Uniformer Raum Summierbarkeit Pattern language Right angle PRINCE2 Quicksort Electric generator Directed graph Slide rule Digital filter Game controller Functional (mathematics) Line (geometry) Letterpress printing Division (mathematics) Device driver Protein Rule of inference Field (computer science) Power (physics) Revision control Crash (computing) Programmschleife Natural number Operator (mathematics) String (computer science) Representation (politics) Utility software Associative property Directed graph Boss Corporation Pairwise comparison Graph (mathematics) Gender Poisson-Klammer Boilerplate (text) Coroutine Limit (category theory) Vector potential Performance appraisal Loop (music) Computer animation Logic Predicate (grammar) Personal digital assistant Social class Iteration Object (grammar)
Slide rule Electric generator Computer animation Iteration Coroutine Student's t-test Recursion
Slide rule Complex (psychology) Functional (mathematics) Key (cryptography) Code Closed set Electronic mailing list Coroutine Line (geometry) Distance Computer programming Power (physics) Neuroinformatik Message passing Computer animation Different (Kate Ryan album) Matrix (mathematics) Square number Social class Selectivity (electronic) Error message Posterior probability Local ring Partial derivative
will run on next speaker's Joan Sutherland and he's going to take us on a tour of the Jerusalem Post please give a victim few thank you and I can hear me OK the good afternoon and entertainment realizing lay on Friday of a long with and them and so this is iteration iteration iteration as my name a 1st let us think that Islam and
and we know where again telegram and not between links to the slides afterward and I would list of and Edinburgh Scotland query making an online daily cancers sports thing that I'm not only talking about the
hazards mentions this is 3 as the most of programming is found with conditionals and the few other bits and pieces and everything else is canaanites hobbled couples with things and you'll recover this afternoon is and look at something and this has some basic looked at recursion and is just you iterators Digital's Alice comprehension is general expressions generators proteins and then other variants and stuff that you're just really shouldn't be unpleasant on and to use a contrived example of factorial and for the 1st few examples I just to demonstrate some of the basics and the board and the reasonably well and is 1 of the things that you will see that it is considered as a friend on his and you're kind member from the high school math classes for pictorial uh so were buying here is the word in and 326 and so the well that you might as well it's rigidity often and unless you were granted the lips in which had real time performance and and he vector of the wild loop so now can see here the iteration states which is the variable and the calculations and the actual looking itself broken bundled together in these 3 lines Estrella going on here and you never have really right this thing and I like this theory that has Python we can do better the following in so the board for low version of the oil and something like this so we wanted to include a range from 10 to 100 this case legend backwards over my 1 and there and evident remote hours of running of cumulative by by and is from this is nice and this is probably the best way to do this for the value of the program is on the criteria has been moved and region variable so that together and so we could recursion so some of you may have noticed and that for quite a while that's a 4 times 3 factorial and so definition factorial is recursive and answer and in the general case n factorial is n times n minus 1 factor and we can see that quite nicely in this good so here factorial the definition of pictorial includes a called factorial which is this recursion as their here's our escape clause and this will prevent us from looking for repairing forever for large about that for larger values of n as well we could lot of stack and then we get our runtime error so we should probably used for Lagrangian rather than the there and the last of architectural examples as with reduced so organ do just that is powering a claim the
numbers 1 to 4 and then we're going to use to reduce the function and the mole multiply operator to collapse the list of 1 2 4 1 2 into a single value and so has inspired and 3 marriages used in different tools and but previous of visibility and the and this works this is reasonably clever but and where I work and certainly if I was good reading and begin thumbs that that for a nice and suggestion would you mind changing this to 4 as
a slightly more interesting factorial and are iterators and iterative search are created by calling it a on an interval and all things quite confusing and complicated but hopefully will be able to fall and so it terrible implement 1 of 2 protocols iterations protocol would and underwritten method for the sequence protocol which is identical item and we present an integer the and then iterators not intervals iterators implement the iterative approach colleges and under next so here we created 3 where all of us to a list to 3 5 in territory and we just the success of calls the next meal the values 2 3 5 if you call next on an exhaustive literature stop iteration at being and in practice so you never actually to catch intuition because reduces the form so this is this is a little more and more useful for a lot more coming have Fibonacci just to you know to to go for those you had with the trivial examples here it's in a terrible because it implements an agenda items that are getting done there at a site and it's also an iterator because it implements and so it tools and there's logical things genetic tools and then you should have a look at yourself and you start looking adults of the the reasonably good uh 1 of them is that tools and care which is generated forever sequence starting at 0 or the the value of the past and so it's a little bit like arrangements so the bus stop value just stop value know wrong forever and we can also pessimistic about the state of Israel and this is this basically goes on forever a couple of other ones in there that I slice which competitive value it will slice of an introduction to the length and it's kinda like this the slice operator and indeed with with searchable backend which we just saw there and then cycle reasonably interesting so cycle will repeat the values in that our in immediate interior passed through the here considered ABC passed and the cycle media values agency and a again at the end the continue ABC ABC ABC and offer as far as I can tell and in Python 3 some of the buildings like that I take and return iterators rather than previously words it returned a list analyze
convergence and I decided to use a really big font size after these title slides and comprehension didn't fit on the slide which is 1 of the hyphenated like this 1 noted and so it's governments and find a nice way to create lists from an existing literature and portable and there are also already follow with Python and minutes you know all this stuff before but I want to list comprehensions this is the primary
and so here we generate a new list and so imagine we have some people that would pull out of the database and with Django are Amazon something similar like that and we just wanna get people's names through recall name for every P and people making the names and we can also add close to a list comprehension so here we're people not bosses and so my this is the and finally have with list comprehensions we can have multiple for literature structure and multiply the charge on the next and so here we see the problem there 2 3 4 5 6 7 that's what was 1 of those 2 of those 3 and so on and 2nd 2 plus 1 2 plus 2 plus and and so these are all the permutations of 2 dimensional answer generator expressions that generates questions look looking very similar to list comprehensions quickly generative and engineers are also iterators and and this is where it's all a compute
and so if we change the square brackets around brackets we had genera and we don't want to get the name of the values and until we iterate over the generator and so can pass through the year generative list as so in this case we can actually remove it there and rockets from the generative and the instrumentalists and we can see with the values and so this is the same as ours comprehension and there are also useful in for loops if you don't need the intermediate list so rather than going through all of the rather than everything in list and then iterating over the last week and issues of gender expression like this any in likelihood DOA you'd probably just have a for loop over people and then do something appealing and the so generators are very similar to educators and they're doing gender expressions generated generators of the generators so generous and they used to yield keywords and and they give us for free abundant turn on the next as well as the nice side-effect of returning to the yield provisioning and yields an extended we call next so here's another Fibonacci uh example for the 1st time we call next on the on the new Fibonacci will come back to the and and we will get value back and then we can call next again will get another a and another in another and so if remember previous Fibonacci example I would use all this carry on and the generators this crap crash it nature to write and it works the same way so we crafted actually from Ricky convex illegal values and 1 1 2 3 5 8 13 and 21 but with careful with these as well as in iterators have every passenger lists we can end up in an infinitely and which is where we would use it to tools to isolate yield from that and the other is the yield keyword pattern or the the 2nd of the 3 dimensions could possibly 3 to yield formalizes to delegate to something to it so in In this change in Python Ardis's yields from was added in Python 33 and but before 3 3 this is a reasonably common pattern to see which is and uniform action exon-exon yield text and this is fine now but in like 3 3 and we can do this from the just maybe slightly nicer and that's all there is to build from using bunch wasted iterate agree intervals iterators generators and encouraging the somewhat related and but there are a lot of attention and there they also use the yield keyword which is why I can have included here as well and they're useful for creating pipelines of operations and what we did is we yield to the right that's my right that you're right on the right hand of the assignment and this allows us to send values into the quality so previously yielding values I will overgenerate there were sending values into a generator and so we can see yields here on the right hand side of the item equals the assignment and and references to be able to send values in here and so the advantage of being lasting on a friday is I can add these things of learned this week like a strings at my slides attuned morning and go to this morning actually so so that the view the we use this we call next but to to do what's called trying to quarantine and so just advantages to the 1st field and controls turned back to where we are limited starts and evaluation so it's and Tom and our printers can add value 0 1 2 2 to the front of our are strings so here we we so when we get to just omega and this is again this is the best I could think of our heritage and had to so visually represent quarantine and what we're going to call this static protein shake and major pipelines most you have this sort 1 shortly so a slightly different version here were a comparison of predicted functions so this open any idea the where the predicted on that nothing is true and so these effective to understand what's going on here is we're going to create as a predicate where check the 2nd letter is you and and it's only this because it's because of my examples and so can see doesn't pass associate and the name is imprinted with the just class of her name is provided and then again from a dozen passes he's not going the and the problem of the stories that we saw tight upper filtering logic and printing and so once again is also a sink and these are not these are these are useful but not sufficient the through skip over this and this is the logo wild basically what we're doing 0 no sorry we're not and so here are going to pass the sink into this quality and and then every time you send value this protein and we're going to send onto the same so you can see this as a job becoming more of pipe the less of a less of a sink and about the security in a decorated top here here is defined basically what we're doing is I would just sort of automatically priming effect called the next and then we return to obtained protein and the reasons you don't necessarily want to do this if you call a self the starter protein and but for the rest of the slides have the 2nd useful thing to have and remove some of the boilerplate will usually and there is also currently their career in the same biological and that's different to the sum of those 2 things so our filler that we've just seen is no pipe rather than missing and so there are no tutorials 1 your side and how we use it is we can conclude printers sink at the the top there and we have still apply which we are predicates to print people who can drive on the passive printer into taxi drivers there and for people a single people choose what type drivers filled which will then send them entrepreneur and so it can see here that you people can drive a rule John so my wife and I can do and there's a slightly more useful and we can maybe start to see how this might become useful and and it looks like this to die a small small 1 so can send values and on the left hand side there and it comes through the filter and it may be conceived through the on we can start to build up some quite interesting uh pipelines and so the units of utility is a Semantic of this according to passing a list of things and were just the fact that we refinery are and the thing is sent to teach all of are and same and proteins to get past so and this is my work if we could create a log which is of great whenever a ball still earn a driver filter and which also sent along and there were pretty achieve 14 which takes both balls and drive was set people and again and we can see here that role of Prince twice because he is both the boss and the driver so she comes through people have villas John comes through the driver filler and the sequence the possible while every uses I'm not entirely sure but it's it's just want to think about and to to to right and here is a visual representation of the so those left insensible Boston driver and potential impact the and so therefore something a bit different which you
shouldn't do so our property by this even when fairly simple tend to look at a bit like this and the thing at the end is always deeply nested amino from from PET 20 that the flatbed nested in other languages including bastion electoral include have a nice constructs and for dealing with this sort of thing where region type things together so here's a whole bunch of magic and whether graph are proteins in a partial they're more the the partial and this powerful company or object which overlooks the power operator and this could certainly be take it up a bit there's a lot of weird stuff that this is easy to following this is also likened unto upon on there could be but allows us to do this and then this reduces slips this does work and so an example here we then we have this range which is not the actual range that's that's what I had to define myself which will generate the values 10 to 15 so 10 11 12 13 14 with a fella I only even values to get 10 12 14 and it was of the printer and it works an but you don't do this
so that's very much and all I have to have a look at Woods recursion and the 2 tools comprehension generators coroutines and then that's vindication do but
thanks very much for coming and for less again that's matter namely and the slide should be under where students and just and
what the
few thank you very much so questions thanks to the talk and let's see how the message list comprehension in there but there wasn't a yellow sticky note on it saying you shouldn't do that more I wouldn't posterior is that something that you think should postgraduate carry over a distance of 2 because this and maybe square of the that's passive-aggressive is targets how complicated should close cooperation and material for the if you do more than 2 things don't do on rampant and for low so if you are integrated chip on the left hand side from keys and values may be and or you know you have the floor with method which is preferred to this functional filler didn't then slightly more complicated here to right over 2 lines and suggests on and for that and just pending of course 1 of the questions that's again and so it is the method is shown in this kind of composing these pipes with the existence of doesn't quite powerful way of transforming data and this with these reusable components and but you don't tend to see this style of programming very often and and I wondered why you think that might be for you maybe this isn't selection in some way that's quite possible and so the question is why do we not see coroutines and pipelines more often I think it's I think it's just weird I don't think it's it's you can do a lot more easily a lot more sold easier to understand and other ways I I think the 1st talk on the origins someone asked and the 1st question was what was the original problem you're trying to solve and by writing code and there is no wasn't really you don't do it there also true from could agree on this slide with the dominant power again and retrograde what about recommend not to use them so why why not use this here was bad enough that there's just too much going on in and going I don't necessarily suggest you write this style called anyway and that there is there a partials and there are a nested functions there are stars that are acquired there are there's overloading build domestic just to do a little trick and which is to start start to create a pipeline yeah you you can do this stuff that initiative at the same the fruit don't matrix computation just the whole idea training them has been complexes of the things it kind of question I have a christian myself I find myself something sometimes wondering efficient use of the land of the partial or local dissolution of function is to have a preference for a is independent I think you could use of all all 3 I don't I don't know that there's a good answer to that thinking depends what looks good and what the rest of this stuff on the context like and if 1 doesn't generally avoided generally about them I think partial this is reasonably unknowns and because the legend functionals tools which is reasonably unknown so I would probably avoid battle people would probably think of the document so at the beginning of different of influences on the assigned error so please give him a bigger