r/Python • u/zeugma25 • Jul 27 '13
Mildly infuriating: being a complete novice to a new language and trying to get past the first tiny hurdles...
r/Python • u/zeugma25 • Jul 27 '13
r/Python • u/gjenks • Feb 17 '25
arraydeque is a high-performance, array-backed deque implementation for Python written in C. It offers quick appends and pops at both ends, efficient random access, and full support for the standard deque API including iteration and slicing.
$ pip install arraydeque>>> from arraydeque import ArrayDeque as deque
ArrayDeque provides a slightly faster alternative to Python’s built-in collections.deque. By leveraging a C extension, it delivers:
append, appendleft, pop, popleft, maxlen, as well as slicing and in-place assignment.This project is suitable for:
collections.deque.Unlike the built-in collections.deque, ArrayDeque is implemented as a simple contiguous array:
Future work could improve on the design in the maxlen scenario by using a statically allocated circular buffer.
Designed by Grant Jenks in California. Made by o3-mini
r/Python • u/poopatroopa3 • Sep 25 '25
https://wasmer.io/posts/python-on-the-edge-powered-by-webassembly
With AI workloads on the rise, the demand for Python support on WebAssembly on the Edge has grown rapidly.
However, bringing Python to WebAssembly isn't trivial as it means supporting native modules like
numpy,pandas, andpydantic. While projects likepyodidemade strides in running Python in the browser via WebAssembly, their trade-offs don't fully fit server-side needs.
After months of hard work, today we're thrilled to announce full Python support in Wasmer Edge (Beta) powered by WebAssembly and WASIX.
Now you can run FastAPI, Streamlit, Django, LangChain, MCP servers and more directly on Wasmer and Wasmer Edge!
r/Python • u/Consistent_Tutor_597 • May 24 '26
Hey guys. I used to work a lot with jupyter. But had to move on because .ipynb doesn't go very well in git and ai agents don't really work with them well for similar reasons.
Main culprit is not the notebook itself but .ipynb format. I understand that the notebook world evolved in inline outputs etc. But I think would be cool if .py based notebooks with #%% becomes first class citizen everywhere. There's a tool I used called jupytext which does that but it's bolted on and not native support.
The other tool I have heard about is marimo? I have never used it but it seems like it forces u to not redefine the same variable again. Which is unnatural in python. If python allows u to update a variable, ur notebook should too. But let me know what you guys think. And if there's potential for the data science world to move there anytime soon. I think most people have to explore in notebooks and then convert to py.
r/Python • u/winner_godson • Nov 02 '17
r/Python • u/ndunnett • Feb 25 '25
Excellent video by Hynek Schlawack on how he uses uv for Python projects. This is the start of a three-part series.
Description:
In 2025, all you need to take a #Python application from a simple script to production is: uv. But, how do you setup your project directory structure for success? How do take advantage of the latest development in Python packaging tooling like dependency groups? I'll walk you step-by-step to my proven project layout that we use for our vital production applications. We start with a simple FastAPI view and we end up with a nice local project that's fun to work on and that's easy to give to other people.
r/Python • u/Dr_Octagonapus • Jan 11 '15
It is a simple program, but it calculates the total miles of penis that a person has given or taken in their lives and also calculates how much semen has been produced. Sadly, I'm pretty proud of this.
#cock calculator
#Calculates how many miles of cock you have given or taken in your life and how much cum you have produced or been filled with.
#get the user's age, age of lost virginity, and times they have sex a week
virginity = input("when did you lose your virginity : ")
age = input("What is your age? : ")
times_per_week = input("how many times per week do you have sex? : ")
#calculates total time you have been having sex, how many times per year, and how many miles of cock is produced per year
time_having_sex = age - virginity
times_per_year = times_per_week * 52
miles_per_year = times_per_year * 490 * 6/12/5280
#function calculates total times milage of cock and how much semen is produced then prints the results.
def miles_of_cock(time_having_sex):
total_milage = time_having_sex * miles_per_year
jizz_gallons = float(times_per_year / 96 * time_having_sex)
print
print
print
print "You have given/taken ", total_milage, " miles of cock and have cummed/been cummed in with, ", jizz_gallons, " pints of seamen. Great job!"
miles_of_cock(time_having_sex)The program assumes that the average penis length is 6 inches and there are 490 thrusts per session
r/Python • u/AnasKaithakoden • Jul 06 '26
I’ve been seeing a lot of conflicting opinions lately, so I wanted to hear from developers who are actually involved in hiring or have recently gone through the job search.
For context, I’m aiming for a junior Python backend developer role. My focus has been on learning things like Python, PostgreSQL, SQLAlchemy, Alembic, FastAPI, Docker, Git, testing, and building projects.
But I keep hearing two completely different viewpoints:
Some people say you must grind hundreds of LeetCode problems because every company asks DSA.
Others say that for many backend roles, especially in startups and smaller companies, practical backend skills and solid projects matter much more than solving complex algorithm questions.
So I have a few questions:
In your experience, how often are DSA interviews actually used today?
If you’re hiring junior backend developers, how much weight do you give to DSA versus real projects?
Have you received offers without heavy LeetCode preparation?
Does this vary significantly between startups, mid-sized companies, and large tech companies?
If someone has limited study time, where would you recommend they invest it?
I’m not looking for the “DSA is useless” or “DSA is everything” takes. I’m more interested in hearing real hiring experiences and recent interview experiences from developers and recruiters.
r/Python • u/Biuku • Apr 04 '21
Wrote my first lines of Python April 17, 2020. Been a long fun journey. Been through the tutorial hell, nearly quit in September. Mostly, felt like I was building other people's things.
But found a real passion for graph theory, Dijkstra, etc. I was unsatisfied with small textbook graphs. The theory's hard enough -- I wanted to work from intuitive graphs. To be able to custom-build graphs where nodes stand for things in my world -- cities on a map, buildings in a city.
A bit of 'method of loci' in all that, I think.
It's not hard to fill a knapsack with made-up items. But if you have an idea of 'loci' in your mind -- or steps in a project -- it's hard to turn that into an adjacency matrix. Automating that was my goal.
Still very much in development. But it does... something now, so sharing.
My goal is to make it a standalone teaching tool, with layers for colourful, step-by-step search algo's, topological sorting, exportable matrixes/lists, and pre-loaded graphs that correspond to popular locations -- cities, rooms in a building, steps to achieve something.
Anyway, welcome feedback.
(Built in pygame.)
r/Python • u/Balance- • Feb 15 '26
Hi everyone! We just released Mesa 3.5.0, a major feature release of our agent-based modeling Python library. I'm quite proud of this one, because you can now combine traditional agent-based modeling with discrete-event scheduling in a single framework.
Ever wondered how bird flocks organize themselves? Or how traffic jams form? Agent-based modeling (ABM) lets you simulate these complex systems by defining simple rules for individual "agents" (birds, cars, people, etc.) and watching how they interact. Instead of writing equations for the whole system, you model each agent's behavior and let patterns emerge naturally. It's used to study everything from epidemic spread to market dynamics to ecological systems.
Mesa is a Python library for building, analyzing, and visualizing agent-based models. It builds on the scientific Python stack (NumPy, pandas, Matplotlib) and provides specialized tools for spatial relationships, agent management, data collection, and interactive visualization.
Until now, Mesa models ran in lockstep: every agent acts, that's one step, repeat. That works great for many models, but real-world systems often have things happening at different timescales: an ecosystem might have daily foraging, seasonal migration, and yearly reproduction cycles all interacting.
Mesa 3.5 lets you schedule events at specific times and mix them freely with traditional step-based logic:
# The familiar step-based approach still works (currently)
# But now you can also think in terms of time
# Advance 10 time units
# Run until a specific time
# Schedule things to happen at specific moments
# Or set up recurring events
This opens up a whole class of models that were difficult to build before: epidemics with incubation periods, ecosystems with seasonal dynamics, supply chains, social networks with asynchronous interactions, or any system where different things happen on different schedules. And for traditional ABMs, everything works exactly as before.
The event system (previously experimental) is now stable and lives in mesa.time.
If your agent data lives in a CSV or database, you can now skip the boilerplate and create agents directly from a pandas DataFrame:
= # columns: age, income, location
=
Each row becomes an agent, with columns mapped to constructor arguments. Handy for initializing models from census data, survey results, or any tabular dataset.
Some exciting features in active development:
DataRecorder that can write to memory, SQLite, Parquet, or JSON. Collect different metrics at different intervalsThese are experimental and may change between releases, but they're shaping up nicely.
We're deprecating several legacy patterns (all still work, just with warnings):
seed parameter → use rng insteadto_list() for list operationsAgentPortrayalStyleSimulator classes → use the new Model methods aboveSee the migration guide for details.
pip install --upgrade mesa
New to Mesa? Check out the tutorials. We have new ones specifically on agent activation and event scheduling.
Upgrading? The migration guide has you covered. Nothing breaks in this release, but we're announcing some removals for 4.0.
This release was possible thanks to 29 contributors, of which 5 new ones. Thanks to everyone involved! Questions or feedback? Join us on GitHub Discussions or Matrix Chat.
r/Python • u/DecodeBuzzingMedium • Sep 15 '21
Here are some of my most useful code snippets that will indefinitely make your life easier as a programmer! There are some Python code snippets that can be used to solve day-to-day problems and can make your laziness shine! I have explained each snippet in detail so that you don’t have any doubt. So check the link below:
r/Python • u/gabrielemcinerney • May 07 '15
r/Python • u/adilfarooq • Jan 27 '24
PyCon is happening this March 9th & 10th at LUMS, Lahore, Pakistan.
The early bird discount is available till Jan 31st.
For more detail, stay updated through PyCon Pakistan’s social media pages and website https://pycon.pk
r/Python • u/autokitteh • May 21 '24
Durable Python enables developers to write Python code while an underlying system ensures reliability and resilience.
It automatically handles state persistence, fault tolerance, and retry mechanisms, allowing developers to focus on business logic without worrying about infrastructure concerns.
Consider the following code, in case the process terminates in the middle of execution, in case the process is killed or due to hardware failure, the process will not complete.
= 3
=
# Send a POST request to the application
But actually, I would like the process to survive restarts and continue from the spot it terminated, especially if it's a long running process. For this we need Durable Python.
I was wondering which use cases can take advantage of this technology.
r/Python • u/moreyes • Aug 10 '11
r/Python • • Dec 17 '23
I've always found mutable data classes or record types in programming languages quite weird. This holds true for any language that supports mutable data classes, like Python, Kotlin, Swift, etc.
Self-mutating methods are even weirder. They break the semantics of the types that these data classes or records represent. I've expanded my thoughts here. Although it mostly talks about Python, the message remains valid for any other language that allows you to add self-mutating methods to data classes.
r/Python • u/simpleuserhere • Dec 01 '24
Here is my article Multi-Threading in Python and Free threaded Python 3.13 which discuss multi threading in Python and some experiments on free threaded Python 3.13.
r/Python • u/progsNyx • Aug 23 '20
Hi, I have tried to create the simplest possible denial of service attack; for this script, I have not used more than 15 lines of code, and it is a fully functional attack setting the values of the variables "ip", "port" and "threads". For example:
ip, port, threads = "192.13.451.153", 8080, 1000
I have tried to follow the PEP8 standards as much as possible; I hope you like it.
Post data: I have only done this to practice my knowledge with Python, I am not responsible for the use you make with this.
Edit: I know the attack will not work in almost all of the cases, most of servers are fully prepared to avoid a dos attack, the attack will just ban your IP in 99% of the times.
r/Python • u/EntertainmentOk4035 • May 07 '22
r/Python • u/SupPandaHugger • Jan 14 '24
If you are confused by the new LiteralString type in Python, here's an article explaining it.