Profiling and Analyzing Performance of Python Programs
In this article we will look at the tools and techniques that can help us narrow down our focus and find bottlenecks both for CPU and memory consumption, as well as how to implement easy (almost zero-effort) solutions to performance issues in cases where even well targeted code changes won't help anymore.
https://martinheinz.dev/blog/64
In this article we will look at the tools and techniques that can help us narrow down our focus and find bottlenecks both for CPU and memory consumption, as well as how to implement easy (almost zero-effort) solutions to performance issues in cases where even well targeted code changes won't help anymore.
https://martinheinz.dev/blog/64
martinheinz.dev
Profiling and Analyzing Performance of Python Programs
<p>
Profiling is integral to any code and performance optimization. Any experience and skill in performance optimization that you might already have will n...
Profiling is integral to any code and performance optimization. Any experience and skill in performance optimization that you might already have will n...
This article will describe some common pitfalls, and how the popular practice of logging f-strings could — in certain situations — leave you vulnerable to other types of attacks.
https://dev.arie.bovenberg.net/blog/is-your-python-code-vulnerable-to-log-injection/
https://dev.arie.bovenberg.net/blog/is-your-python-code-vulnerable-to-log-injection/
Arie Bovenberg
Is your Python code vulnerable to log injection?
Following the news on log4j lately, you may wonder if Python’s logging library is safe. After all, there is a potential for injection attacks where string formatting meets user input. Thankfully, Python’s logging isn’t vulnerable to remote code execution.…
Common #Python #interview question:
How to flatten a list of lists (several nested levels)?
Seems itertools.chain only goes one level deep, so let's use some recursion here.
How to flatten a list of lists (several nested levels)?
Seems itertools.chain only goes one level deep, so let's use some recursion here.
Here's an alternative if you prefer speed over elegance (without recursion).
This version assumes that you flatten in order to print.
If that is not the case, you may leave out the "[“+... and ...+“]" part before returning the result and apply .split(",") instead, so the last line of flatten should read:
return re.sub("[ \[\]\n]+", "", s).split(",")
This version assumes that you flatten in order to print.
If that is not the case, you may leave out the "[“+... and ...+“]" part before returning the result and apply .split(",") instead, so the last line of flatten should read:
return re.sub("[ \[\]\n]+", "", s).split(",")