text: from collections import OrderedDict
  from django.utils.encoding import smart_bytes
  from django.utils import six
  
  
  def dict_strip_unicode_keys(uni_dict):
      """
      Converts a dict of unicode keys into a dict of ascii keys.
  
      Useful for converting a dict to a kwarg-able format.
      """
      if six.PY3:
          return uni_dict
  
      data = {}
  
      for key, value in list(uni_dict.items()):
          data[smart_bytes(key)] = value
  
      return data
  
  class LimitedSizeDict(OrderedDict):
    def __init__(self, *args, **kwds):
      self.size_limit = kwds.pop("size_limit", None)
      OrderedDict.__init__(self, *args, **kwds)
      self._check_size_limit()
  
    def __setitem__(self, key, value):
      OrderedDict.__setitem__(self, key, value)
      self._check_size_limit()
  
    def _check_size_limit(self):
      if self.size_limit is not None:
        while len(self) > self.size_limit:
          self.popitem(last=False)
  