Join Michele Vallisneri for an in-depth discussion in this video ✓ Solution: Parallel search, part of Python: Programming Efficiently.
- [Instructor] Here's my solution.…I import all packages for this chapter.…I open the file of words with gzip open…in read mode and in text mode.…The object that I get behaves like a regular file,…so I can iterate over the lines.…And I use a list comprehension to strip out the new line…at the end of each.…So here's my list.…Roughly, 235,000.…The target of our search will be the word zygomaticum.…
We can search in chunks of any size.…Traditionally computer scientists like powers of two.…And now let me write a function that we run…on each process.…It will look only within a slicing of the list of words.…And it will use the metaled index…to see the index of the target.…I also need to adjust the index from the local slicing…to the global list.…Last I need to handle the case where nothing is found,…which will raise an exception value error.…
In that case, I return none.…So I set up pool the map.…And I call it passing the initial index for each chunk.…I need to select the only index that is not none.…Let's check.…Check, this concludes the exercise.…
- Designing efficient loops
- Exploiting Python collections
- Writing Pythonic code
- Choosing the best libraries for your tasks
- Downloading webpages with requests
- Parsing HTML with Beautiful Soup
- Manipulating images with Pillow
- Making videos and drawing on maps with matplotlib
- Serving webpages with Jinja2 and Flask
- Working with Python classes
- Taking advantage of functional techniques
- Profiling CPU and memory use
- Exploiting parallelism
Skill Level Intermediate
Learning Python Web Penetration Testingwith Christian Martorella2h 49m Intermediate
1. Installation and Setup
Jupyter notebooks3m 19s
2. Writing Python Efficiently
3. Exploiting Python Libraries
4. Advanced: Python Object-Oriented and Functional Programming
5. Introduction to Performance Optimization in Python
Next steps1m 2s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.