r/Python • • 21h ago

Discussion I've started treating the output of my little Python scripts as a user interface

102 Upvotes

I inherited a bunch of internal Python scripts at work last year. Most of them were perfectly readable, did their job and had been running for years without any major issues.

The annoying part was figuring out what they'd actually done.

One would print "Done" whether it processed 400 files or found nothing to process. Another would silently skip invalid records. To understand the result of a successful run I sometimes had to read the source code.

I've since developed a habit of ending even fairly trivial scripts with a small summary of what was found, what changed, what was skipped and why.

It's probably the smallest change I've made to my coding habits with the biggest practical payoff. Especially when revisiting something I wrote six months ago.

I think we spend a disproportionate amount of time making Python code pleasant for other developers to read compared to making Python programs pleasant for other people to actually run.


r/Python • • 4h ago

News I Built A C++ Powered Python Library Using pybind11 - way faster than python loops

0 Upvotes

Hey everyone, I just published my first C++ powered Python library on PyPI (kaptandanuj-easyhelper) to see how much faster list operations get when you move the loop from Python to C++.

Right now it has an order-preserving unique() function for int, float, and str lists. Under the hood it uses a templated C++ std::vector + std::unordered_set with reserve() pre-allocation, bound with pybind11.

On a list of 100k items, it beats a normal Python for loop + set()

Here how you install it

pip install kaptandanuj-easyhelper