New answers tagged python-3.x
7
votes
Algorithm "sort except zero"
I would suggest you use NumPy for anything that manipulates collections of numbers of the same type. A NumPy array is a more efficient container than a list in this case, an the package contain a ...
7
votes
Algorithm "sort except zero"
301_Moved_Permanently's answer is great and changes the performance from \$O(nk\log(n))\$ to \$O(n\log(n))\$.
The change results in a measurable impact on performance.
To satiate both my curiosity and ...
12
votes
Accepted
Algorithm "sort except zero"
Most of the work will be done by your call to sorted. You just need to make sure to not make too much extra fluff around that call.
One particular call that may ...
2
votes
CPU emulator written in python (Adjustable Microcode!)
This is a von Neumann machine, which is risky. It introduces the possibility of a whole category of bugs that by definition cannot exist on a Harvard machine. If you're able, rewrite to represent the ...
2
votes
Accepted
NumPy script to convert BGR to HSL and back
I find the code easy to read; there are no legibility issues (within the context that you need to understand Numpy).
It's a good idea that you're doing division safety checks, but you should simplify ...
1
vote
Application install code- Need to remove Nested Loops and make code more compact and readable. Code installs application and its version as per req
I think more sentiments to support the advice by @J_H would be :
Nesting if statements
You may like statement nesting If you are a beginner just like me, But after ...
2
votes
NumPy script to convert BGR to HSL and back
Floating-point arithmetic is very slow and since you're doing a lot of it, it plays a major part in slowing things down. Since you're dealing with colours, you can replace floats with ints in the ...
1
vote
2D Point subclass of complex builtin
You want to learn about metaclasses. That's good! You also want to develop a geometry tool following best practices - that's also good! Where this immediately falls apart is
Pure Python is expressly ...
2
votes
Accepted
2D Point subclass of complex builtin
doctests
Kudos for the doctests, they are very helpful.
Doctests are documentation I can believe!
They do not bit rot (since failing tests are quickly noticed).
...
6
votes
Generate random password from a list of allowed characters
Security
The biggest red flag that I see is using random to generate passwords. This is warned against in the python docs on random.
Warning: The pseudo-random ...
4
votes
Generate random password from a list of allowed characters
What you have posted is not complete since it is missing definitions and will not execute as is.
What is this function supposed to do?
The title of your post explains in slight detail what the ...
3
votes
Accepted
Metaclass Wrapping Builtin to Enforce Subclass Type
shebang
#!/usr/bin/env python
The shebang looks beautiful, thank you.
Everyone should implement like this.
Very portable, and it obeys ...
1
vote
Application install code- Need to remove Nested Loops and make code more compact and readable. Code installs application and its version as per req
You voiced several concerns:
Need to remove Nested Loops and
make code more compact and
readable.
I don't know what (1) is all about,
since I only counted a single ...
Top 50 recent answers are included
Related Tags
python-3.x × 5312python × 5115
beginner × 816
performance × 630
programming-challenge × 436
algorithm × 323
object-oriented × 276
web-scraping × 205
game × 183
numpy × 176
pandas × 159
time-limit-exceeded × 140
tkinter × 136
strings × 134
reinventing-the-wheel × 104
parsing × 86
tic-tac-toe × 85
beautifulsoup × 85
csv × 81
random × 80
console × 76
file-system × 75
mathematics × 74
hash-map × 73
file × 73