Mastering Python's Built-in time Module (Overview)
The Python time
module provides many ways of representing time in code, such as objects, numbers, and strings. It also provides functionality other than representing time, like waiting during code execution and measuring the efficiency of your code.
This course will walk you through the most commonly used functions and objects in time
.
By the end of this course, you’ll be able to:
- Understand core concepts at the heart of working with dates and times, such as epochs, time zones, and daylight savings time
- Represent time in code using floats, tuples, and
struct_time
- Convert between different time representations
- Suspend thread execution
- Measure code performance using
perf_counter()
00:00
Hello, and welcome to this Real Python video tutorial series on the Python time
module, which you can find in the Python standard library. Over the course of this series, you’re going to learn the core concepts of working with time in Python, like epochs, time zones, and daylight savings time.
00:18
You’ll learn to represent time in your Python code using floats, tuples, and the struct_time
object, and actually using strings as well. And, of course, you’ll learn to convert between all of those different time representations.
00:31
Finally, you’ll learn a couple of cool functions the time
module offers you to evaluate your code’s performance, like the sleep
function to suspend thread execution, and the perf_counter
function, which allows you to measure code performance really precisely with a short-range timer. So, let’s get to it.
Become a Member to join the conversation.