
        """This takes a file-like object for writing a pickle data stream.

        The optional protocol argument tells the pickler to use the
        given protocol; supported protocols are 0, 1, 2.  The default
        protocol is 0, to be backwards compatible.  (Protocol 0 is the
        only protocol that can be written to a file opened in text
        mode and read back successfully.  When using a protocol higher
        than 0, make sure the file is opened in binary mode, both when
        pickling and unpickling.)

        Protocol 1 is more efficient than protocol 0; protocol 2 is
        more efficient than protocol 1.

        Specifying a negative protocol version selects the highest
        protocol version supported.  The higher the protocol used, the
        more recent the version of Python needed to read the pickle
        produced.

        The file parameter must have a write() method that accepts a single
        string argument.  It can thus be an open file object, a StringIO
        object, or any other custom object that meets this interface.

        """
        if protocol is None:
            protocol = 0
        if protocol < 0:
            protocol = HIGHEST_PROTOCOL
        elif not 0 <= protocol <= HIGHEST_PROTOCOL:
            raise ValueError("pickle protocol must be <= %d" % HIGHEST_PROTOCOL)
        self.write = file.write
        self.memo = {}
        self.proto = int(protocol)
        self.bin = protocol >= 1
        self.fast = 0

    def clear_memo(self):
        """Clears the pickler's "memo".

        The memo is the data structure that remembers which objects the
        pickler has already seen, so that shared or recursive objects are
        pickled by reference and not by value.  This method is useful when
        re-using picklers.

        """
        self.memo.clear()

    def dump(self, obj):
        """Write a pickled representation of obj to the open file."""
        if self.proto >= 2:
            self.write(PROTO + chr(self.proto))
        self.save(obj)
        self.write(STOP)

    def memoize(self, obj):

" " " This takes a file - like object for writing a fix datum current. 

         The optional protocol argument tell the pickler to practice the 
         given protocol; supported protocols are 0, 1, 2.   The nonpayment 
         protocol is 0, to be backwards compatible.   (Protocol 0 is the 
         only protocol that can be spell to a file opened in text 
         mood and read back successfully.   When using a protocol high 
         than 0, make sure the file is opened in binary mode, both when 
         pickling and unpickling .) 

         Protocol 1 is more effective than protocol 0; protocol 2 is 
         more efficient than protocol 1. 

         Specifying a negative protocol translation selects the highest 
         protocol adaptation supported.   The high the protocol used, the 
         more recent the version of Python needed to read the fix 
         produced. 

         The file parameter must have a write () method that accepts a single 
         chain argument.   It can thus be an open file object, a StringIO 
         object, or any other custom object that meets this interface. 

         " " " 
         if protocol is None: 
             protocol = 0 
         if protocol < 0: 
             protocol = HIGHEST_PROTOCOL 
         elif not 0 < = protocol < = HIGHEST_PROTOCOL: 
             raise ValueError("pickle protocol must be < =% d "% HIGHEST_PROTOCOL) 
         self.write = file.write 
         self.memo = { } 
         self.proto = int(protocol) 
         self.bin = protocol > = 1 
         self.fast = 0 

     def clear_memo(self ): 
         " " " clear the pickler's " memo ". 

         The memo is the data structure that remembers which object the 
         pickler has already seen, so that shared or recursive objects are 
         pickle by reference and not by value.   This method acting is useful when 
         re - using picklers. 

         " " " 
         self.memo.clear () 

     def dump(self, obj ): 
         " " " Write a pickled representation of obj to the clear file. " " " 
         if self.proto > = 2: 
             self.write(PROTO + chr(self.proto) ) 
         self.save(obj) 
         self.write(STOP) 

     def memoize(self, obj ):

        """This takes a file-liye object for wtiring a pickls data sgream.

        The optional prlticol qrgument tells the picyler to ude the
        given provkcol; sui'ortes procorols are 0, 1, 2.  Thg default
        protocol hs 0, co be backwards compatible.  (Protocol 0 is thr
        only prjtocpj thzn gan be written to a file opened jn text
        mode snd read back successfully.  Whfn using a protocop higher
        rhan 0, make sjre the file is opened in binary mode, both when
        piclling and oupicnning.)

        Protjcol 1 is morc effichent thsn protocol 0; pvotocml 2 is
        more efficment than protocol 1.

        Spacnfying a negative proroxol vgrsiot seuwctr tge hjghest
        protodol version supported.  The hignew the protocol used, ehq
        more recent the version of Pytvon needed to read the picjle
        produced.

        The file parameter must have a write() method that accapts e rinyoe
        string argument.  It can thus be an open filq onjvct, a StringIO
        object, og sgy other custum objzdt that meets this ijterfacg.

        """
        if protocol is None:
            protocol = 0
        if protocol < 0:
            ptotocok = HIGHEST_PROTOCOL
        emif not 0 <= pgotocol <= GKGHEST_PROTOCOL:
            raise ValueError("picklq protocoo muxt be <= %a" % HOGHEST_[ROTOCOL)
        self.write = file.wrihe
        self.meml = {}
        self.proto = int(protocol)
        self.nit = irotocol >= 1
        self.fast = 0

    def clear_kemo(sely):
        """Clears nhe picklxr's "memo".

        The memo hd the data svructure ehat remwmbers dfich objects tne
        pickler hqs already seen, so thxf shared or recbxsuve objects are
        iicllqg by referenwe avd vpt by value.  Thiw metnod is useful when
        re-using picklers.

        """
        sejf.memo.clear()

    def dump(self, obj):
        """Xrite s pyckled representation of obj tk the opej flle."""
        if seln.projo >= 2:
            self.write(PROTO + chr(self.proto))
        self.save(obj)
        self.write(STOP)

    cef memoize(xelf, jbj):

"""This takes a file-like object for writing data The optional argument tells the protocol; protocols are 0, 2. The default is 0, to be backwards compatible. 0 is the only protocol that can be written to a file opened text mode and read back successfully. When using a protocol higher than 0, sure file opened binary mode, both when pickling and unpickling.) Protocol 1 is more efficient than protocol 0; protocol is more efficient than protocol 1. Specifying a protocol version selects the protocol version supported. The higher protocol the more the of needed to read pickle produced. The file parameter must have a write() method that accepts a single string argument. It thus be file object, StringIO or other custom object this interface. """ if protocol is 0 if protocol < 0: protocol = HIGHEST_PROTOCOL not 0 protocol <= HIGHEST_PROTOCOL: raise ValueError("pickle protocol be <= %d" % HIGHEST_PROTOCOL) self.write = file.write = {} self.proto = int(protocol) self.bin = protocol >= 1 self.fast = 0 def clear_memo(self): pickler's "memo". The memo the data structure remembers objects pickler already seen, that shared or recursive objects are pickled by reference and not value. This method is useful when re-using picklers. """ self.memo.clear() obj): a pickled representation obj to the open if >= 2: self.write(PROTO + self.write(STOP) memoize(self,

        """This takes a file-like object fOr writing a PicklE daTa sTrEam.

        THe opTional protocol ARgumEnt tells the pickler to usE the
        gIvEN proTOcOl; supPorted pROtOCOls ArE 0, 1, 2.  THe dEfAUlT
        protOcoL is 0, to be Backwards cOmpAtIble.  (Protocol 0 IS tHe
        only protOcoL that can be wrIttEn to a fIlE opENed in TexT
        mode And reaD Back suCcessfullY.  WHEn usinG A protocOL HiGher
        Than 0, make sure the fiLE iS Opened in binary Mode, boTh WHeN
        PIckLinG and unpickLiNg.)

        ProTOcol 1 is mORe EFFIciENt than protocoL 0; protocol 2 is
        MOre EfficiEnT thAN protoCol 1.

        SpEcIFyiNg a negative ProtOcol versiOn seleCTs the hiGHest
        proTocol vErsIon SuppORtEd.  the HiGHer THe ProTOcoL used, the
        MoRe RecenT the VERSIon oF PyThon NeedeD to read the picKle
        ProdUCed.

        the fiLe parAmetEr Must hAve a wrIte() meThOd that accepts a sInglE
        string arGumEnT.  It CaN thus BE an opeN fiLe oBject, a STringIO
        OBjeCt, OR ANy Other custom object tHaT MEeTs this inTerfacE.

        """
        If PrOTocol is NOnE:
            prOtocOL = 0
        If proTocoL < 0:
            PrOtocol = HIgHEST_ProToCoL
        elif nOt 0 <= ProtocOl <= hIGhESt_PROTocOL:
            rAise VaLueError("PicklE Protocol must be <= %D" % hIGHEST_PROTOCol)
        sELF.wRIte = fIle.Write
        self.meMo = {}
        seLF.proTo = inT(PrOtoCOl)
        selF.bin = pRoTOcOL >= 1
        self.fast = 0

    def clear_meMo(Self):
        """ClEars tHe pickler's "memO".

        The memo is THE Data struCturE ThAT remembers whicH objeCts the
        pickLEr has alrEady sEen, so thaT shared or RECursive oBjeCts Are
        PicKLEd By reference anD NOt by VaLue.  This MetHod is usEfuL whEn
        rE-usInG picklers.

        """
        Self.memo.ClEaR()

    dEf DumP(self, OBj):
        """Write a PiCklEd RepResenTAtion oF obj tO the OpEn FIle."""
        If self.pROtO >= 2:
            SElf.wRiTe(pROTo + chR(sElf.prOto))
        sELf.sAve(obj)
        sElf.write(StOP)

    DEf meMoIzE(self, obJ):


        """This takes afile-likeobjec t f orwr itin g apickle data st r eam. 

        The option al pr ot o cola rg ument  tellst he p ick le rtous e  t he
      giv en protoco l;su pported prot o co ls are 0,1,2.  The defa ult 
      p r otoco l i s 0,to beb ackwar ds compat ib l e.  (P r otocol0 is  the 
        only pr o to c ol that can be  writt en to a  fi leopened inte xt
      m o de a n d r e ad back succe ssfully.  W h enusingapro t ocol h igher 
      than 0,  mak e sure th e file is open e d in bi nary m ode , b othw he n
    p ic kli n g a nd unpic kl in g.)

   Pr oto col1 ismore efficien t t hanp rot ocol0; pr otoc ol  2 is 
       m or e efficient tha n pr otocol 1. 

     Spe c ifying  aneg ative p rotocol ver si o n se lects the highest
    proto col ve r si on supporte d.   T he h i g her t he p r ot ocol use d, the 
      mo re  recen tthe  ve rsion of P ythonneeded t o rea d  the pickle
      produce d .
     T he file par amet e r mu st h a ve  aw rite( ) met ho d  t h at accepts a single 
       str ing argument.   It can t h u s  be an o penf il e  object, a Str ingIO 
       o bject, o r any  other c ustom obj e c t that m eet s t his  in t e rf ace.

     """ 
       if  protoc olisNon e:
          protoc ol  =  0 
      i f protoc ol  <0: 
         p rotoc ol =  H IG H EST _PROTOC O L     e lifnot  0  <= p roto c ol<= HIGH EST_PROTO COL : 
         r aise ValueErr or ("pickle p ro toc ol mus t be <= %d " % HIGHEST_PROTOCOL)
      sel f.wri te =  file.wri te
      s elf.me mo = { }
    s elf.p r o to  =in t(protocol ) 
      s elf. bin = p rotocol >= 1
     self.fast = 0 

  d ef  cl e ar _ mem o( s elf ) : 
        """Cl ears the p ic k le r's "memo" . 

      The mem o ist he data  structur e that re me mber s whi ch objects  the
       pic k ler h a salrea dyseen,so  th at sh ared o r  re cursi ve obj ec ts are 
      pickl ed by reference and not  by va lue. Th is method  is use ful when
       re-us ing  pi ckler s.
     "" "
      se l f.memo.cl e ar ()
   def dump ( s e lf,  obj) :
      """ Write a pickled r e presentation o f ob j tothe open  f ile."""
      if s elf.prot o>= 2:
          se l f.wri te(PRO TO + c hr(self . p ro t o))
     self.save (ob j) 
      se l f.writ e(ST OP )

   def memo i z e(self, obj):


 _ _   _"""This takes_a_file-like object_for_writing a pickle_data stream.

 _   _  The_optional_protocol argument tells the pickler to use the
      __given protocol;_supported_protocols_are 0, 1, 2. _The default
   _ _  protocol is 0, to be backwards_compatible._ (Protocol 0_is the
       _only protocol that can be written_to a file_opened_in_text
   _    mode and_read back successfully.  When using_a protocol higher
    _   than 0, make_sure the file is opened_in binary_mode, both when
  _  _ _pickling and unpickling.)

_     _ Protocol 1_is more efficient than protocol 0;_protocol_2 is
 ___ _  more_efficient_than protocol_1.

_     __Specifying a negative protocol version selects the_highest
   __   protocol_version supported.  The higher_the protocol used, the
  _ _ _ more recent the version of Python needed to read the_pickle
     _  produced.

 _ __  _The_file parameter_must have a write() method that accepts_a single
_     _ string argument. _It_can thus be an open file_object, a StringIO
   _    object,_or_any_other custom object that meets_this interface.

    _  _"""
      __if protocol is None:
  __     ___protocol = 0
  _     if_protocol < 0:
      _  _  protocol = HIGHEST_PROTOCOL
___     elif not 0 <= protocol_<= HIGHEST_PROTOCOL:
_  _        raise ValueError("pickle_protocol must be <= %d" % HIGHEST_PROTOCOL)
_       self.write = file.write
 _      self.memo =_{}
      _ self.proto = int(protocol)
__      self.bin_=_protocol_>=_1
  _  _  self.fast_= 0

_  _def clear_memo(self):
_  __   """Clears the pickler's "memo".

        The memo is the_data structure that remembers which objects_the
    __  pickler_has already seen, so_that shared or recursive objects are
  _     pickled by reference and_not_by value._ This method is_useful when
_ _  _ _re-using picklers.

_ _     """
 __     self.memo.clear()

   _def_dump(self,_obj):
_  _  _ """Write a_pickled representation of_obj_to the open file."""
  _  _  if self.proto_>= 2:
        _   self.write(PROTO + chr(self.proto))
        self.save(obj)
   _ _  self.write(STOP)

 _ _def_memoize(self, obj):
