This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
In this python implementation of LRUCache, | |
We are using a hashmap `cache={}` to be able to retrieve data at O(1) and | |
using a Doubly Linked List to maintain the order of keys to know which one | |
are most recently used to least recently used as we move from head to tail. | |
""" | |
class Node: | |
def __init__(self, key, value, next=None, prev=None) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
class DynamicFieldsModelSerializer(serializers.ModelSerializer): | |
''' | |
A ModelSerializer that takes an additional `fields` argument that | |
controls which fields should be displayed. | |
''' | |
def __init__(self, *args, **kwargs): | |
super(DynamicFieldsModelSerializer, self).__init__(*args, **kwargs) |