Skip to content

Instantly share code, notes, and snippets.

@ellisandrews
Last active August 20, 2020 04:11
Show Gist options
  • Save ellisandrews/21bc592a45e26b67782ba71075cb578a to your computer and use it in GitHub Desktop.
Save ellisandrews/21bc592a45e26b67782ba71075cb578a to your computer and use it in GitHub Desktop.
Constant time complexity
from typing import Any, Dict, List
# Example 1
def list_lookup(list_: List[Any], index: int) -> Any:
"""Lookup a value in a list by index."""
return list_[index]
# Example 2
def dict_lookup(dict_: Dict[Any, Any], key: Any) -> Any:
"""Lookup a value in a dictionary by key."""
return dict_[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment