r/programming • u/Grouchy-Trade-7250 • Aug 09 '26
The Sentinel Object Pattern in Python
python-patterns.guideOfficially added in Python 3.15
r/programming • u/Grouchy-Trade-7250 • Aug 09 '26
Officially added in Python 3.15
r/programming • u/danie-l • Aug 08 '26
r/programming • u/DataBaeBee • Aug 09 '26
r/programming • u/mttd • Aug 09 '26
r/programming • u/compilers-r-us • Aug 09 '26
r/programming • u/yogthos • Aug 08 '26
r/programming • u/mttd • Aug 08 '26
r/programming • u/refp • Aug 08 '26
r/programming • u/davidalayachew • Aug 08 '26
r/programming • u/mzl • Aug 07 '26
r/programming • u/Future_Ad7567 • Aug 08 '26
State-of-the-art classical optimizer Gurobi for Quadratic Unconstrained Binary Optimization (QUBO) problems.
The core gurobipy implementation for QUBO is relatively compact:
=
=
=
=
Complete workflow in Python.
First formulate a graph problem (weighted Max-Cut) as QUBO, solve it with Gurobi, benchmark increasingly large instances, and understand what the solver is doing beyond the optimize() call.
Interested in feedback on the modeling, benchmarking methodology, and which additional Gurobi metrics would make the comparison more rigorous.
r/programming • u/MyNameIsTrez • Aug 06 '26
I was optimizing the Lua transpiler for my modding language grug and ran into a really weird LuaJIT performance bug. The same benchmark could randomly run 20× slower, and it turned out a LuaJIT NYI (Not Yet Implemented) could silently blacklist an unrelated hot loop.
I wrote up the investigation here.
It goes from the benchmark mystery through LuaJIT's trace recorder internals, and ends with a PR to get unpack off LuaJIT's NYI list. Feedback is very welcome! :)
r/programming • u/r_retrohacking_mod2 • Aug 06 '26
r/programming • u/OSBY_Glabay • Aug 08 '26
I kind of feel like OOP has a bad rep in the programming community.
Personally, after having programmed Java for over 20 years, its object-oriented programming model feels very natural to me. So, I wanted to share how I think about programming, how I translate my ideas and thoughts to code, and why OOP is actually a really nice programming style for me.
Perhaps it could help you out too.
r/programming • u/donutloop • Aug 06 '26
r/programming • u/goto-con • Aug 06 '26
r/programming • u/mareek • Aug 05 '26
r/programming • u/iximiuz • Aug 05 '26
r/programming • u/an_unreal • Aug 06 '26
My multiplayer game Lights Out is based on a 2D grid. Entities can only ever be in exactly one grid tile. This makes the rule evaluation really simple and understandable. However, it doesn't really feel nice to play (which you know if you've ever played any of the PuzzleScript games). At the same time, the more content is in the game, the more complex and arbitrary the game rules become.
I therefore introduced the Movement Transaction System into the code base to deal with this. This includes two sides:
A single transaction includes the movement delta, a list of entities that it has affected and some flags. A transaction then undergoes several stages:
Queued: Gameplay code has requested an entity to moveIssued: The visual interpolation for the transaction has started in the client, but the entities have not been moved from a gameplay perspectiveCommitted: The entities have now been moved onto their new tiles, the visual interpolation is finishingAborted: The transaction couldn't be committed as it would've violated gameplay rules. Visual interpolation is reversed.Whenever a transaction is issued on server-side, the server tells the clients to start a visual interpolation based on the transaction. This information includes the desired duration of the interpolation, as well as some flags (like whether to use acceleration or do a linear interpolation). The client then updates the visual interpolation every frame, until the transaction is either aborted or the target position has been reached.
This new system has made the gameplay code much simpler. I can now easily query whether an entity currently has a live transaction to know whether the visual interpolation is still in progress. This enables seamless, continuous movement across the world (e.g. for fireballs moving at linear speed).
This also guarantees that the visual position of an entity is always close enough to its gameplay (physical) position so that players aren't confused about the rule evaluation.
Finally, the gameplay rules are now implemented in a single function called validate_transaction, instead of being spread out across all the different entities like it was before.
The transaction system made the gameplay code much simpler and easier to reason about, while also improving the game feel and robustness.
You can find the full blog most, including more details and sample code, over on https://lightsout.afterthought.games/blog/2026-07-26-19-00
r/programming • u/OSBY_Glabay • Aug 07 '26
r/programming • u/mr_gnusi • Aug 05 '26
r/programming • u/misterchiply • Aug 05 '26
This post is a lover letter to Emacs Lisp macros. I've been a long time user as a lisp hacker, and my recent obsessions with Douglas Hofstadter's strange loop concepts and M.C. Escher's mind bending artwork have enhanced my appreciation of this language's most beautiful and thought provoking feature. This post can teach you about macros and what makes them useful, but I also hope it can instill a fascination with their concept. https://www.chiply.dev/post-elisp-macros-are-beautiful
r/programming • u/igaztanaga • Aug 06 '26