course notes,

Code Versioning

Duc-Tri Duc-Tri Follow Jan 01, 2025 · 1 min read

Semantic Versioning

Summary: Given a version number Major.Minor.Patch, increment the:

  • Major version when you make incompatible API changes
  • Minor version when you add functionality in a backward compatible manner
  • Patch version when you make backward compatible bug fixes Additional labels for pre-release and build metadata are available as extensions to the Major.Minor.Patch format.

Example:

# 1.0.0
def add_numbers(a, b, c):
    return a + b + c
    
# 1.0.1
def add_number(a, b, c):
    # faster and more secure :)
    ...
    
# 2.0.0
def add_numbers(a, b, c, d):
    return a + b + c + d
    
# but the version could have been 1.1.0 if the changes were non-breaking
def add_numbers(a, b, c, d = 0):
		return a + b + c + d

# pip install cool_library
add_numbers(1, 2, 3, 0)