code: def append(self, item):
          
          f = self.f(item)
          if callable(f):
              score = f()
          else:
              score = f
  
          if not self.duplicates:
              for s, i in self.data:
                  if s == score and item == i:
                      #item is a duplicate, don't add it
                      return False
  
          if self.length and len(self.data) == self.length:
                  #Fixed-length priority queue, abort when queue is full and new item scores worst than worst scoring item.
                  if self.minimize:
                      worstscore = self.data[-1][0]
                      if score >= worstscore:
                          return False
                  else:
                      worstscore = self.data[0][0]
                      if score <= worstscore:
                          return False
  
          if self.blockworse and self.bestscore != None:
              if self.minimize:
                  if score > self.bestscore:
                      return False
              else:
                  if score < self.bestscore:
                      return False
          if self.blockequal and self.bestscore != None:
              if self.bestscore == score:
                  return False
          if (self.bestscore == None) or (self.minimize and score < self.bestscore) or (not self.minimize and score > self.bestscore):
              self.bestscore = score
          bisect.insort(self.data, (score, item))
          if self.length:
              #fixed length queue: queue is now too long, delete worst items
              while len(self.data) > self.length:
                  if self.minimize:
                      del self.data[-1]
                  else:
                      del self.data[0]
          return True
docs: Adds an item to the priority queue (in the right place), returns True if successfull, False if the item was blocked (because of a bad score)