A Japanese AI company called Preferred Networks has a mature open-source library for NumPy/SciPy calculations on GPUs.
It's called CuPy π.
For massive datasets, it is often enough to replace a single line:
The same array operations can run on CUDA up to 100 times faster.
What it can do:
π Highly compatible with existing NumPy and SciPy code
π Dramatically reduces the need to rewrite code or learn new syntax
π» Supports not only NVIDIA CUDA but also AMD ROCm architectures
Keep in mind:
β Only faster for massive arrays; small datasets will run slower due to CPU-to-GPU data transfer lag
β Strictly bound by your physical GPU VRAM limits (can cause out-of-memory errors).
β Covers most major math functions, but does not replicate 100% of NumPy/SciPy modules.
The project is completely open-source and battle-tested since 2015 π: https://github.com/cupy/cupy
It's called CuPy π.
For massive datasets, it is often enough to replace a single line:
import cupy as cpThe same array operations can run on CUDA up to 100 times faster.
What it can do:
π Highly compatible with existing NumPy and SciPy code
π Dramatically reduces the need to rewrite code or learn new syntax
π» Supports not only NVIDIA CUDA but also AMD ROCm architectures
Keep in mind:
β Only faster for massive arrays; small datasets will run slower due to CPU-to-GPU data transfer lag
β Strictly bound by your physical GPU VRAM limits (can cause out-of-memory errors).
β Covers most major math functions, but does not replicate 100% of NumPy/SciPy modules.
The project is completely open-source and battle-tested since 2015 π: https://github.com/cupy/cupy
β€4
Forwarded from Programming Quiz Channel
What is the biggest advantage of using a set instead of a list when checking whether an item exists?
Anonymous Quiz
16%
Sets preserve insertion order better
10%
Sets allow duplicate values
44%
Membership checks are typically much faster
30%
Sets use less memory in every situation
π 15 Python Built-in Functions Every Developer Should Know
You don't always need another library.
Python already ships with powerful built-in functions that can make your code cleaner, shorter, and faster.
1. enumerate() - Loop through items while automatically keeping track of their index.
2. zip() - Combine multiple lists together element by element.
3. map() - Apply the same function to every item in an
iterable.
4. filter() - Keep only the elements that satisfy a condition.
5. sorted() - Return a new sorted list without changing the original.
6. any() - Returns
7. all() - Returns
8. sum() - Quickly calculate the total of numeric values.
9. min() / max() - Find the smallest or largest value instantly.
10. len() - Count the number of items in any iterable.
11. set() - Remove duplicate values while creating a collection of unique items.
12. isinstance() - Check whether an object belongs to a specific type.
13. range() - Generate sequences of numbers efficiently.
14. reversed() - Iterate over data in reverse order without modifying it.
15. help() - Open the built-in documentation for almost any Python object.
Learning these built-ins will make your code look much more "Pythonic" and save you from writing unnecessary loops.
You don't always need another library.
Python already ships with powerful built-in functions that can make your code cleaner, shorter, and faster.
1. enumerate() - Loop through items while automatically keeping track of their index.
2. zip() - Combine multiple lists together element by element.
3. map() - Apply the same function to every item in an
iterable.
4. filter() - Keep only the elements that satisfy a condition.
5. sorted() - Return a new sorted list without changing the original.
6. any() - Returns
True if at least one item is truthy.7. all() - Returns
True only if every item is truthy.8. sum() - Quickly calculate the total of numeric values.
9. min() / max() - Find the smallest or largest value instantly.
10. len() - Count the number of items in any iterable.
11. set() - Remove duplicate values while creating a collection of unique items.
12. isinstance() - Check whether an object belongs to a specific type.
13. range() - Generate sequences of numbers efficiently.
14. reversed() - Iterate over data in reverse order without modifying it.
15. help() - Open the built-in documentation for almost any Python object.
Learning these built-ins will make your code look much more "Pythonic" and save you from writing unnecessary loops.
β€4
π Reading Python Error Messages
Suppose you see this.
Instead of guessing, break it down.
TypeError β You're performing an operation on an incompatible type.
NoneType β The value is
not iterable β Python expected something it could loop over, like a list or tuple.
A common cause:
When you see this error, ask yourself:
"Which variable was supposed to contain a list but ended up being None?"
Suppose you see this.
TypeError: 'NoneType' object is not iterable
Instead of guessing, break it down.
TypeError β You're performing an operation on an incompatible type.
NoneType β The value is
None.not iterable β Python expected something it could loop over, like a list or tuple.
A common cause:
def get_users():
print("Loading users...")
for user in get_users():
print(user)
get_users() doesn't return anything, so it returns None by default. Python can't loop over None.When you see this error, ask yourself:
"Which variable was supposed to contain a list but ended up being None?"
β€4
π Python Time Complexity Cheat Sheet
β List
β’ Access by index β O(1)
β’ Append β O(1)
β’ Insert at beginning β O(n)
β’ Delete from middle β O(n)
β’ Search (
Best for: Ordered collections where fast indexing matters.
β Dictionary (dict)
β’ Lookup β O(1)
β’ Insert β O(1)
β’ Update β O(1)
β’ Delete β O(1)
Best for: Fast lookups using keys.
β Set
β’ Add β O(1)
β’ Remove β O(1)
β’ Membership test β O(1)
Best for: Removing duplicates and fast membership checks.
β Tuple
β’ Access β O(1)
β’ Search β O(n)
Best for: Read-only collections that shouldn't change.
β List
β’ Access by index β O(1)
β’ Append β O(1)
β’ Insert at beginning β O(n)
β’ Delete from middle β O(n)
β’ Search (
in) β O(n)Best for: Ordered collections where fast indexing matters.
β Dictionary (dict)
β’ Lookup β O(1)
β’ Insert β O(1)
β’ Update β O(1)
β’ Delete β O(1)
Best for: Fast lookups using keys.
β Set
β’ Add β O(1)
β’ Remove β O(1)
β’ Membership test β O(1)
Best for: Removing duplicates and fast membership checks.
β Tuple
β’ Access β O(1)
β’ Search β O(n)
Best for: Read-only collections that shouldn't change.
β€3
Think Python.pdf
899.8 KB
One of our members asked for a Python Book
This book, Think Python, is an introduction to Python programming for beginners.
It starts with basic concepts of programming; it is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression.
This book, Think Python, is an introduction to Python programming for beginners.
It starts with basic concepts of programming; it is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression.
π₯3
π 10 Useful String Methods in Python
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
These methods appear in almost every real-world Python project.
1.
split() β Break text into pieces.2.
join() β Combine multiple strings.3.
replace() β Replace part of a string.4.
strip() β Remove extra spaces.5.
startswith() β Check prefixes.6.
endswith() β Check suffixes.7.
find() β Locate text.8.
count() β Count occurrences.9.
upper() / lower() β Change case.10.
capitalize() β Capitalize the first letter.These methods appear in almost every real-world Python project.
β€5
Forwarded from Programming Quiz Channel
What exception does Python raise when you divide by zero?
Anonymous Quiz
16%
ValueError
72%
ZeroDivisionError
10%
ArithmeticError
1%
TypeError
π§ Think Like Python
Suppose you want to know if a username exists.
π» Many beginners write:
π’ Python gives you a simpler solution.
Less code. More readable. Usually faster to understand.
Whenever Python has a built-in way to express an idea, prefer it.
Suppose you want to know if a username exists.
π» Many beginners write:
found = False
for user in users:
if user == "Alex":
found = True
break
π’ Python gives you a simpler solution.
found = "Alex" in users
Less code. More readable. Usually faster to understand.
Whenever Python has a built-in way to express an idea, prefer it.
β€3
Python & NumPy Review Slides.pdf
1.1 MB
Python Notes for AI was requested by one of you. And here it is...
You can drop any future resource requests here.
You can drop any future resource requests here.
β€4
Python Script to Retrieve Saved Wi-Fi Passwords (Windows)
Someone requested this⦠We thought it might help.
π» How to use the above code:
1. Open any text editor (Notepad, VS Code, etc.)
2. Copy and paste the code above
3. Save the file as
4. Open Command Prompt or PowerShell as Administrator
5. Navigate to the folder where you saved the file
6. Run the command:
β The script will list all the Wi-Fi networks that are saved on your computer along with their passwords.
β οΈ This only works for networks that are already saved on your Windows PC. It cannot crack or find passwords of networks you have never connected to.
Someone requested this⦠We thought it might help.
import subprocess
def get_wifi_passwords():
# To get list of all saved Wi-Fi profiles
profiles_data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="ignore").split('\n')
profiles = [line.split(":")[1].strip() for line in profiles_data if "All User Profile" in line]
print("\nSaved Wi-Fi Networks & Passwords:\n" + "-"*40)
for profile in profiles:
try:
# To get password for each profile
profile_info = subprocess.check_output(
['netsh', 'wlan', 'show', 'profile', profile, 'key=clear']
).decode('utf-8', errors="ignore").split('\n')
password = [line.split(":")[1].strip() for line in profile_info if "Key Content" in line]
print(f"Network : {profile}")
print(f"Password: {password[0] if password else 'None / Open Network'}\n")
except:
print(f"Network : {profile}")
print("Password: Unable to retrieve\n")
if __name__ == "__main__":
get_wifi_passwords()
π» How to use the above code:
1. Open any text editor (Notepad, VS Code, etc.)
2. Copy and paste the code above
3. Save the file as
wifi_passwords.py4. Open Command Prompt or PowerShell as Administrator
5. Navigate to the folder where you saved the file
6. Run the command:
python wifi_passwords.py
β The script will list all the Wi-Fi networks that are saved on your computer along with their passwords.
β οΈ This only works for networks that are already saved on your Windows PC. It cannot crack or find passwords of networks you have never connected to.
β€3π₯2
π¦ What Should You Learn After Python Basics?
β Functions & Modules
β¬οΈ
β Object-Oriented Programming
β¬οΈ
β File Handling
β¬οΈ
β Exception Handling
β¬οΈ
β Virtual Environments
β¬οΈ
β Git & GitHub
β¬οΈ
β Choose a Path:
β’ Web Development
β’ Automation
β’ Data Science
β’ Machine Learning
β’ Cybersecurity
β’ Backend APIs
Python is just the language.
Your specialization is what turns it into a career.
β Functions & Modules
β¬οΈ
β Object-Oriented Programming
β¬οΈ
β File Handling
β¬οΈ
β Exception Handling
β¬οΈ
β Virtual Environments
β¬οΈ
β Git & GitHub
β¬οΈ
β Choose a Path:
β’ Web Development
β’ Automation
β’ Data Science
β’ Machine Learning
β’ Cybersecurity
β’ Backend APIs
Python is just the language.
Your specialization is what turns it into a career.
β€3π1
β‘οΈ append() vs extend()
These two methods look similar, but they do completely different things.
Output:
Now compare it with:
Output:
π
π
This small difference causes countless beginner bugs.
These two methods look similar, but they do completely different things.
numbers = [1, 2, 3]
numbers.append([4, 5])
print(numbers)
Output:
[1, 2, 3, [4, 5]]
Now compare it with:
numbers = [1, 2, 3]
numbers.extend([4, 5])
print(numbers)
Output:
[1, 2, 3, 4, 5]
π
append() adds one object.π
extend() adds every element.This small difference causes countless beginner bugs.
β€5
Forwarded from Programming Quiz Channel
What does the Python slice list[::-1] do?
Anonymous Quiz
22%
Removes the last element
56%
Reverses the list
16%
Sorts the list descending
5%
Returns an empty list
π 10 Python Modules You Probably Didn't Know Existed
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
1.
textwrap - Format long blocks of text.2.
difflib - Compare files or strings.3.
fractions - Work with exact fractions.4.
decimal - High precision decimal arithmetic.5.
calendar - Generate calendars programmatically.6.
uuid - Generate unique IDs.7.
secrets - Create cryptographically secure tokens.8.
pprint - Print nested data structures beautifully.9.
platform - Detect operating system information.10.
getpass - Securely read passwords from the terminal.β€5π1
π Reading Python Error Messages
Suppose you see this.
Instead of panicking, read it from left to right.
TypeError β The operation uses the wrong data type.
str β Python found a string.
int β It also found an integer.
π You're trying to combine two incompatible types.
Suppose you see this.
TypeError: can only concatenate str (not "int") to str
Instead of panicking, read it from left to right.
TypeError β The operation uses the wrong data type.
str β Python found a string.
int β It also found an integer.
π You're trying to combine two incompatible types.
β€3
β‘οΈ Why Is This Loop So Slow?
Imagine you're checking whether thousands of usernames exist.
If
For every lookup.
Now imagine
That's why changing this:
into this:
can dramatically speed up membership checks without changing the rest of your code.
Imagine you're checking whether thousands of usernames exist.
for username in usernames:
if username in banned_users:
...
If
banned_users is a list, Python checks one element at a time.Alice?
Bob?
Charlie?
David?
...
For every lookup.
Now imagine
banned_users is a set. Python doesn't search one by one. It uses a hash table to jump directly to where the value should be.That's why changing this:
banned_users = [...]
into this:
banned_users = {...}can dramatically speed up membership checks without changing the rest of your code.
β€3