import time
= time.time()
started print("I sleep now for 1.23 seconds")
1.23)
time.sleep(print("Measured execution time is", time.time() - started)
I sleep now for 1.23 seconds
Measured execution time is 1.2366728782653809
Minna Heim, Matthias Bannert, Franziska Oschmann
May 20, 2024
Znüni with Franziska Oschmann at ETH KOF Swiss Economic Institute on May 30, 09:45.
“[…] And Python continued to see gains in its usage across GitHub with a 22.5% year-over-year increase driven, in part, by its utility in data science and machine learning.” – GitHub Octoverse Report on the top programming languages.
Much of Python’s popularity stems from its flexibility and general purpose appeal1, yet the idea of this article is to point at Python’s use in research and to present an opportunity to efficiently improve your skills in a programming language that has become ubiquitous in many fields of research. While our innate curiosity as researchers is definitely enough of a driver to get us started with a trending programming language, getting past the first steps requires more commitment and hence comes with prerequisities and opportunity costs.
In other words, the goal of the RSEED Znüni with Franziska Oschmann is to find out whether a deeper dive into Python is for you. The Fast Python workshop is a great opportunity for researchers to improve effectively. Though you should already be somewhat familiar with Python to get the most out of 4-day workshop, you do not have to be an expert, and definitely not a computer scientist.
Often it is not easy for novice or intermediate programmers to see why whatever works or good enough for me is not good enough. One example of an important skill when problems get harder or require more throughput, is the ability to benchmark one’s code. Benchmarking is important in order to assess one’s need for computing resources and can facilitate cooperation with software engineering experts.
Consider the simplest possible benchmark using the time Python library.
import time
started = time.time()
print("I sleep now for 1.23 seconds")
time.sleep(1.23)
print("Measured execution time is", time.time() - started)
I sleep now for 1.23 seconds
Measured execution time is 1.2366728782653809
Fast Python will cover the basics of profiling and optimizing in Python, and introduce you to some of the most common tools and techniques. It will also provide some best practices for writing fast and efficient Python code including parallel computing.
The help you assess not only your readiness, but also what it would take to catch up in case you are not there yet, the team at SIS developed a quick self-assessment2 to help you evaluate your starting point. Can you guess the results from execution of the following Python code snippets? Can you explain the snippets and their results to others?
Do not be discouraged if you cannot answer all snippets immediately! You can use a computer to execute these snippets step by step and work to understand them. The course won’t start tomorrow and there is plenty of great material to help you catch up.
False 344
[25, 16, 9, 0, 1]
l = []
for i in range(10):
if i % 3 == 0:
pass
elif i % 3 == 1:
continue
else:
i *= 10
if i == 6:
break
l.append(i)
print(l)
[0, 20, 3, 50]
When: 2024, tbd.
Where: ETH, in-person.
The 4-day workshop will be fully refunded to committed participants, i.e., participants who take part in all sessions, who are SIS service subscribers. Typically, groups, chairs or insitutions are subscribed to SIS – so make sure to check with your unit whether they have an SIS suscription.
You can find the original, stand-alone version of the workshop self-assessment on the course Gitlab page↩︎