Vectorize all the things! Using linear algebra and NumPy to make your Python code lightning fast.
We took a naive KNN implementation and made it 1000x faster. The secret wasn't a new language, but vectorized NumPy operations.
#1about 3 minutes
Why Python loops become slow at scale
Traditional loops over lists become a major performance bottleneck when processing large amounts of data.
#2about 5 minutes
Representing data with vectors, matrices, and NumPy arrays
Learn the fundamentals of linear algebra, where data points are vectors, datasets are matrices, and NumPy arrays provide the data structure.
#3about 3 minutes
A high-level overview of the KNN algorithm
The k-nearest neighbors algorithm classifies data points by finding the most common label among their closest neighbors in a vector space.
#4about 4 minutes
Coding a slow baseline KNN with Python lists
A walkthrough of an unoptimized k-nearest neighbors implementation demonstrates the severe performance issues caused by nested loops.
#5about 3 minutes
Vectorizing the distance calculation to remove a loop
Replace the inner loop for calculating Manhattan distance with a single vectorized subtraction operation on NumPy arrays.
#6about 9 minutes
Eliminating nested loops with NumPy array broadcasting
Use array reshaping and broadcasting to perform all pairwise distance calculations simultaneously, avoiding explicit replication and nested loops.
#7about 3 minutes
Optimizing neighbor selection with NumPy sorting and slicing
Gain final performance improvements by replacing Python's list sorting with NumPy's faster sorting algorithms and efficient array slicing.
#8about 6 minutes
How memory layout makes NumPy arrays so fast
NumPy arrays are faster because they store data in a contiguous block of memory, which is more efficient for the CPU to process than the scattered memory of Python lists.
#9about 22 minutes
Audience Q&A on performance and data science
Answers common questions about NumPy's underlying C implementation, hyperparameter tuning, memory management, and career paths in data science.
Related jobs
Jobs that call for the skills explored in this talk.
Matching moments
00:46 MIN
Accelerating computations with the Vector API
Modern Java 25
03:29 MIN
Leveraging vernacular developers for faster innovation
Enterprise Python: Software That Lives Long And Prosper
04:58 MIN
Optimizing code with nvmath-python and a case study
Accelerating Python on GPUs
02:18 MIN
Gaining performance with the Vector API and elastic metaspace
The Cool Thing about Cool Things in Java 16 & 17 LTS
02:56 MIN
Using high-level frameworks like Rapids for acceleration
Accelerating Python on GPUs
04:05 MIN
Using NVIDIA libraries to easily accelerate applications
WWC24 - Ankit Patel - Unlocking the Future Breakthrough Application Performance and Capabilities with NVIDIA
10:18 MIN
A progressive approach to programming GPUs in Python
Accelerating Python on GPUs
05:12 MIN
Boosting Python performance with the Nvidia CUDA ecosystem
The weekly developer show: Boosting Python with CUDA, CSS Updates & Navigating New Tech Stacks
All the videos of Halfstack London 2024!Last month was Halfstack London, a conference about the web, JavaScript and half a dozen other things. We were there to deliver a talk, but also to record all the sessions and we're happy to share them with you. It took a bit as we had to wait for th...
Luis Minvielle
The 13 Best Python Libraries for Developers in 2025Python still stands as one of the three most popular programming languages because it’s incredibly useful for data scraping, data engineering, and data analysis — meaning non-programmers that are handy with numbers, such as accountants or Economics B...
Chris Heilmann
Dev Digest 134 - Where pixels sing?News and ArticlesWeAreDevelopers LIVE Data and Security Day is on Wednesday, 25/09/2024. Learn about OPC UA Updates, Best Practices for Using GitHub Secrets, Passwordless Web 1.5, Emerging AI Security Risks, Data Privacy in LLMs and get a chance to t...
Chris Heilmann
Dev Digest 109 -Egg-citing things…As we are heading into the Easter break, here are some things to spend some time on. There's resources on improving the performance of your code and you hear from the winners of CODE100 Amsterdam what it was like to be on stage. Also, hang tight as t...
From learning to earning
Jobs that call for the skills explored in this talk.