skillfed

codetiming

A flexible, customizable timer for your Python code.

codetiming v1.4.0 1.0M downloads/30d#4,485 on PyPI312
Permissive license Abandoned released

What it is and what it does

codetiming provides a Timer class for measuring code execution time in Python. It supports three usage patterns—as a standalone class with explicit start/stop calls, as a context manager for timing code blocks, and as a decorator for timing function calls. The Timer accepts optional arguments to customize output formatting (via a text template), redirect output to a logger function, and optionally display text when the timer starts.

The package includes named timer aggregation: when you create a Timer with a name, elapsed times accumulate in a class-level dictionary (Timer.timers) that provides statistics methods like mean, median, min, max, stdev, and count. The text formatting is template-based using .format() rather than f-strings, and can be a callable for custom time formatting. A single runtime dependency on dataclasses ensures compatibility with older Python versions.

Use it for:

  • Measure execution time of specific code blocks during development and debugging without external profiling tools
  • Track performance of repeated operations and gather statistics (mean, max, stdev) across multiple runs
  • Add timing instrumentation to functions using decorators for quick performance monitoring
  • Redirect timer output to logging frameworks instead of print for integration with application logging
  • Benchmark different implementations by timing them with named timers and comparing accumulated statistics

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Measures elapsed time in Python code using a flexible Timer class that works as a decorator, context manager, or standalone object, with customizable output formatting and named timer aggregation.

Yes, if you need a lightweight, zero-configuration timer for development and learning. The package is stable and has no known vulnerabilities, but install with the understanding that it is no longer maintained—no bug fixes or feature updates will be released. For production performance monitoring, consider a more actively maintained alternative.

Install

codetiming on PyPI

pip

pip install codetiming

uv

uv add codetiming

poetry

poetry add codetiming

Installing codetiming

Before you install

Installation is straightforward with no compiled dependencies. However, the package has been abandoned since November 2022 (over 1375 days without updates), so no active maintenance or bug fixes should be expected.

License in practice

Licensed under MIT (permissive), which allows free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

from codetiming import Timer

# As a context manager
with Timer(name="example"):
    # Code to time
    pass

# As a decorator
@Timer(name="function")
def my_function():
    pass

# As a class
t = Timer()
t.start()
# Code to time
elapsed = t.stop()

Verify before relying

  • Whether the package works correctly with Python versions beyond 3.11 despite no recent releases
  • Current compatibility with modern Python async/await patterns
  • Whether accumulated timer data in Timer.timers persists correctly across different execution contexts

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies 1 — dataclasses
Maintenance abandoned — 1,375 days since the last release
Last repo commit
First released
Downloads 1,024,712/month — #4,485 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: codetiming-1.4.0-py3-none-any.whl

Keywords: timer, class, contextmanager, decorator

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: MacOSOperating System :: MicrosoftOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: EducationTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: MonitoringTyping :: Typed

Tags

python code timingmeasure execution timeperformance profiling decoratorcontext manager timerelapsed time tracking
profilingbenchmarkingdevelopment-tools

More Python Modules packages