L ibdZddlZddlmZmZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl Z ddlZddlZddlZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZej:ZeZ ejBZ"ejFZ$ejJZ&ejNdk(Z(dZ)e(re*e+jXjZZ)ejBZ.dZ/d Z0d Z1d Z2d Z3d Z4ejjdk\rdZndZdZ6dRdZ7dRdZ8dZ9dZ:ejvdZefZ?e jZ@e jZAiZBejjD]\ZEZFe*eFe*useEeBeF<dZGdZHdZIdZJdZKdZLdZMd ZNeNGd!d"ZOd#ZPd$ZQeOfd%ZRd&ZSd'ZTd(ZUd)ZVd*ZWd+ZXdSd,ZYdSd-ZZdSd.Z[d/Z\d0Z]d1Z^d2Z_d3Z`d4Zad5Zbd6Zcd7Zdd8Zed9Zfd:Zgd;Zhd<Zid=Zjd>Zkd?Zld@ZmdAZndBZodCZpdDZqdEZrdFZsdGZtdHZudIZvdJZwdKZxdLZyejjejejjejejjejiZ~dMZGdNdOejZdTdPZdTdQZejejcZZeZy)Ua Pickler class to extend the standard pickle.Pickler functionality The main objective is to make it natural to perform distributed computing on clusters (such as PySpark, Dask, Ray...) with interactively defined code (functions, classes, ...) written in notebooks or console. In particular this pickler adds the following features: - serialize interactively-defined or locally-defined functions, classes, enums, typevars, lambdas and nested functions to compiled byte code; - deal with some other non-serializable objects in an ad-hoc manner where applicable. This pickler is therefore meant to be used for the communication between short lived Python processes running the same version of Python and libraries. In particular, it is not meant to be used for long term storage of Python objects. It does not include an unpickler, as standard Python unpickling suffices. This module was extracted from the `cloud` package, developed by `PiCloud, Inc. `_. Copyright (c) 2012-now, CloudPickle developers and contributors. Copyright (c) 2012, Regents of the University of California. Copyright (c) 2009 `PiCloud, Inc. `_. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Berkeley nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. N)ChainMap OrderedDict)Enum) _getattribute)CellTypePyPyct5tj|}|0tjj }|t|<|t |<ddd|S#1swYSxYwN)_DYNAMIC_CLASS_TRACKER_LOCK_DYNAMIC_CLASS_TRACKER_BY_CLASSgetuuiduuid4hex_DYNAMIC_CLASS_TRACKER_BY_ID) class_defclass_tracker_ids n/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/joblib/externals/cloudpickle/cloudpickle.py_get_or_create_tracker_idrlsh $G:>>yI  ##zz|// 9I +I 6=F ()9 : G  G s AAA#c|0t5tj||}|t|<ddd|S|S#1swY|SxYwr )r r setdefaultr )rrs r_lookup_class_or_trackrvsV# ( J4?? )I:J +I 6  J 9  J s 5?ct|tjstdt |d|j t jvrt|dtj|j y)aRegister a module to make its functions and classes picklable by value. By default, functions and classes that are attributes of an importable module are to be pickled by reference, that is relying on re-importing the attribute from the module at load time. If `register_pickle_by_value(module)` is called, all its functions and classes are subsequently to be pickled by value, meaning that they can be loaded in Python processes where the module is not importable. This is especially useful when developing a module in a distributed execution environment: restarting the client Python process with the new source code is enough: there is no need to re-install the new version of the module on all the worker nodes nor to restart the workers. Note: this feature is considered experimental. See the cloudpickle README.md file for more details and limitations. %Input should be a module object, got  insteadzN was not imported correctly, have you used an `import` statement to access it?N) isinstancetypes ModuleType ValueErrorstr__name__sysmodules_PICKLE_BY_VALUE_MODULESaddmodules rregister_pickle_by_valuer(so& fe.. /@V XVWWckk)h/ /    1ct|tjstdt |d|j t vrt|dt j|j y)zr?r5r's r _whichmodulerHs#|T2K #{{//1779 V : %m+~fe&6&67  VT*c1""2    s,B B  B ct|tjstt |tr!t ||}|y|\}}t | St|tjr(t |ry|jtjvStdjt |j)aTest whether an function or a class should be pickled by reference Pickling by reference means by that the object (typically a function or a class) is an attribute of a module that is assumed to be importable in the target Python environment. Loading will therefore rely on importing the module and then calling `getattr` on it to access the function or class. Pickling by reference is the only option to pickle functions and classes in the standard library. In cloudpickle the alternative option is to pickle by value (for instance for interactively or locally defined functions and classes or for attributes of modules that have been explicitly registered to be pickled by value. r?Fz*cannot check importability of {} instances) rr FunctionType issubclasstype_lookup_module_and_qualnamer7rr!r"r# TypeErrorformat)r>r?module_and_namer's r_should_pickle_by_referencerRs#u))*jcD.I5cE  "& 1&999 C)) * *# .||s{{** 8 ? ?S @R@R S  r)c| t|dd}| t|dd}t||}|y|dk(rytjj |d}|y t ||}||ury||fS#t $rYywxYw)N __qualname__r!rC)rErHr"r#r rAttributeError)r>r?r5r'obj2s rrNrNs |sND1 |sJ-sD)Kj [[__[$ /F ~ VT* 3 4< s A-- A98A9c&tj|}|tt|Dcic]}|d}}|jrF|jD]7}t |t j s|jt|9|t|<|Scc}w)z:Find all globals names read or written to by codeblock co.N) _extract_code_globals_cacher _walk_global_ops co_constsrrCodeTypeupdate_extract_code_globals)co out_namesr?consts rr]r]9s+//3I-=R,@ADT4ZA A << CeU^^4$$%:5%AB C+4#B' Bs Bcg}|D]}t|tjst|ds+|js8|j dz}t tjD]x}||j|st|t|djd}|t|jz rW|jtj|z|S)a!Find currently imported submodules used by a function. Submodules used by a function need to be detected and referenced for the function to work correctly at depickling time. Because submodules can be referenced as attribute of their parent package (``package.submodule``), we need a special introspection technique that does not rely on GLOBAL-related opcodes to find references of them in a code object. Example: ``` import concurrent.futures import cloudpickle def func(): x = concurrent.futures.ThreadPoolExecutor if __name__ == '__main__': cloudpickle.dumps(func) ``` The globals extracted by cloudpickle in the function's state include the concurrent package, but not its submodule (here, concurrent.futures), which is the module used by func. Find_imported_submodules will detect the usage of concurrent.futures. Saving this module alongside with func will ensure that calling func once depickled does not fail due to concurrent.futures not being imported __package__r2N)rrrhasattrrbr!listr"r# startswithsetlenr<co_namesappend)codetop_level_dependencies subimportsxprefixr?tokenss r_find_imported_submodulesrpRs4J #= q%** +=) ZZ#%FS[[) =#(? c&km!4!:!:3!?@F!C $66"))#++d*;< ==$ r) STORE_GLOBAL DELETE_GLOBAL LOAD_GLOBALc8|dk(rtStt|S)N ClassType)rMrErrJs r _builtin_typervs { 5$ r)c#Ktj|D]%}|j}|tvs|j'yw)zBYield referenced name for global-referencing instructions in code.N)disget_instructionsopcode GLOBAL_OPSargval)rjinstrops rrYrYs;%%d+ \\  ,, s -AAct|jDcic]!}dj||j|#}}t|jdk(r|jdj}n7i}t |jD]}|j |jg}|jD] \}} ||}||ur|j|"|D]}|j||Scc}w#t$rYMwxYw)zDRetrieve a copy of the dict of a class without the inherited method.r3r) sorted__dict__joinrg __bases__reversedr\rFriKeyErrorpop) clskclsdictinherited_dictbase to_remover?value base_values r_extract_class_dictrs 5;3<<4HIqrwwqz3<<?*IGI 3==Qq)22S]]+ 1D  ! !$-- 0 1I}} e '-J "  &  D N%J   s&C8C== D D ctjdtdtjvrytjd}t |dsy|j |S)zfReturn whether `func` is a Tornado coroutine function. Running coroutines are not supported. zis_tornado_coroutine is deprecated in cloudpickle 3.0 and will be removed in cloudpickle 4.0. Use tornado.gen.is_coroutine_function directly instead.)categoryz tornado.genFis_coroutine_function)warningswarnDeprecationWarningr"r#rcr)funcgens ris_tornado_coroutinersX  MM $  CKK' ++m $C 3/ 0  $ $T **r)c>t|tj|Sr ) __import__r"r#rJs r subimportrs t ;;t r)ctj|}|jj|tj|jd<|SN __builtins__)rrrr\builtins)r?varsmods rdynamic_subimportrs=   4 CLL#+#4#4CLL Jr)cF |jS#t$r tcYSwxYwr ) cell_contentsr_empty_cell_valuecells r_get_cell_contentsrs(!!!! !  !s   c|S)zCreate a new instance of a class. Parameters ---------- cls : type The class to create an instance of. Returns ------- instance : cls A new instance of ``cls``. r/rs rinstancers  5Lr)c eZdZdZedZy)rzSentinel for empty closures.c|jSr )r!rs r __reduce__z_empty_cell_value.__reduce__s ||r)N)r!rBrT__doc__ classmethodrr/r)rrrs&r)rcFt|d<tj|||||Sr)rrrK)rjglobalsr?argdefsclosures r_make_functionrs%*GN   dGT7G DDr)c* fdjdS)NcSr r/rsrz"_make_empty_cell.. sDr)r)AssertionError __closure__rs@r_make_empty_cellrs  % %a ((r)c8t}|tur||_|Sr )rrr)rrs r _make_cellrs  D %%" Kr)cjDcic]\}}tj||c}}tj||d|ifd}t ||Scc}}w)aBuild dynamic class with an empty __dict__ to be filled once memoized If class_tracker_id is not None, try to lookup an existing class definition matching that id. If none is found, track a newly reconstructed class definition under that id so that other instances stemming from the same class id will also reuse this class definition. The "extra" variable is meant to be a dict (or None) that can be used for forward compatibility shall the need arise. metaclassc&|jSr )r\)ns type_kwargss rrz&_make_skeleton_class..*s;AWr))rFr"internr new_classr) type_constructorr?basesrrextrarvskeleton_classs ` r_make_skeleton_classrsc 1<0A0A0CD13::a=!#DK__ ek#346WN ""2N CC Es A"c|d}|j}|j||} |jD] \} } | | | < |j|||| } || _|| _t || S)a6Build dynamic enum with an empty __dict__ to be filled once memoized The creation of the enum class is inspired by the code of EnumMeta._create_. If class_tracker_id is not None, try to lookup an existing enum definition matching that id. If none is found, track a newly reconstructed enum definition under that id so that other instances stemming from the same class id will also reuse this enum definition. The "extra" variable is meant to be a dict (or None) that can be used for forward compatibility shall the need arise. ) __class__ __prepare__rF__new__rBrTr) rr?qualnamemembersr'rr enum_basemetacls classdict member_name member_value enum_classs r_make_skeleton_enumr0s$b I!!G##D%0I%,]]_.! \!- +.$yAJ"J&J !"2J ??r)cPtj|g||||d}t||S)N)bound covariant contravariant)typingTypeVarr)r?r constraintsrrrtvs r _make_typevarrOs;     #  B ""2B 77r)c|j|j|j|j|jt |fSr )r! __bound____constraints__ __covariant____contravariant__rr>s r_decompose_typevarrZs=     !#&  r)ct||j}|tt|fSt |drtt|fSt |fS)NrJr)rNr!rrr7rE)r>rQs r_typevar_reduceresT2#CLLIO1#677 '(: ;1#677 _ %%r)cBdt|divrd}nd}t||S)N__orig_bases__rr)rE)typ bases_attrs r _get_basesrrs.73 B77 & ! 3 ##r)c|r#tj|jStj|jSr )rfromkeyskeysdictr> is_ordereds r_make_dict_keysrs7##C(--//}}S!&&((r)c|r)tdt|DjSt|Dcic]\}}|| c}}jScc}}w)Nc3*K|] \}}||f ywr r/).0i_s r z$_make_dict_values..s=daAq6=s)r enumeratevalues)r>rrrs r_make_dict_valuesrsL=in==DDFF!*30A1077990s AcX|rt|jS|jSr )rrFrs r_make_dict_itemsrs%3%%''yy{r)ci}d|jvr|j|d<|jjdd}t|tr||d<t ||j t||t|dfS)NrBr) rrBr rpropertyrMr!rr)r>rrs r_class_getnewargsrszKs||#$'NN L!|| D1H(H%"* J S  3!#&  r)c|Dcic]}|j|j}}|j|j|j||j t |dfScc}wr )r?rrr!rTrBr)r>ers r_enum_getnewargsrs\(+,1qvvqww,G,    !#&  -sAc|Sr r/)retvals r_file_reconstructorr s Mr)c dj|jdj|j|j|j|j |j |j|jd}t|j}|Dcic]!}||jvs||j|#}}|j$ttt|j}nd}t|jt!j"|j%||d<||d<|j&j)Dcic]\}}dj||}}}||fScc}wcc}}w)Nr)r!rT__annotations____kwdefaults__ __defaults__rBrrr/_cloudpickle_submodules __globals__)rr!rTr rrrBrrr]__code__rrdmaprrp itertoolschainrrrF)r slotstate f_globals_refr f_globalsclosure_valuesrstates r_function_getstatersLGGDMM* 1 12//--))oo<<'' I*$--8M1>XA!tGWGWBWD$$Q''XIX #c"4d6F6FGH ,E yy'7'7'9>J,I'( )Im(,}}':':'< =tq!RWWQZ] =E = ) 'Y$ >sE-'E- E2ct|}|jddtt|tj r|jdd|jdd|jdd|jdd}|E|jddt j |\}}}}|Dcgc] }| c}|d<n|Dcgc]}|c}|d<d|vrYt|jtr|j|jn#|jD]}|j|d|jdd|ifScc}wcc}w) N __weakref__ _abc_cache_abc_negative_cache_abc_negative_cache_version _abc_registry _abc_impl __slots__r) rrrLrMabcABCMeta _get_dumprr#r )r>rregistryrsubclass_weakreftype_rs r_class_getstater*s8!#&G KK t$$s)S[[)  L$' )40 148;;5   KK T *"%--"4 Xq!QOW#X;K$4$6#XGK 8@#@eE#@GK g cmmS ) KK &]] % At$ % KK D! R=%$Y$As ;E Ect|\}}|Dcic]}|j|j}}dD]}|j|d|D]}|j|||fScc}w)N)_generate_next_value__member_names_ _member_map_ _member_type__value2member_map_)r*r?rr)r>rrrrattrnamemembers r_enum_getstater3s(-GY(+,1qvvqww,G,$  Hd#$ F I -sA(c<dj|j}td|jD}td|jD}td|j D}td|j D}t|dr|j|j|j|j|j|j|j|j|||j ||j"|j$|j&|j(||f}nt|dr|j|j|j|j|j|j|j|j|||j ||j$|j&||f}nNt|dr|j|j|j|j|j*|j,|j.|j|j|j||j ||j$|j0|j2|j4|||j6|j8f}n|j|j|j|j|j|j|j|j|||j ||j$|j0||f}t:j<|fS) zcode object reducer.rc3 K|]}|ywr r/rr?s rrz_code_reduce..Ds3dT3 c3 K|]}|ywr r/r6s rrz_code_reduce..E99r7c3 K|]}|ywr r/r6s rrz_code_reduce..Fr9r7c3 K|]}|ywr r/r6s rrz_code_reduce..Gr9r7co_exceptiontable co_linetableco_nmeta)rco_nametuplerh co_varnames co_freevars co_cellvarsrc co_argcountco_posonlyargcountco_kwonlyargcount co_nlocals co_stacksizeco_flagsco_coderZ co_filename co_qualnameco_firstlinenor=r< co_framesizeco_ndefaultargsr> co_lnotabco_exc_handlers co_jump_table co_free2reg co_cell2regrr[)r>r?rhrArBrCargss r _code_reducerV5sggckk"G 3cll33H999K999K999Ks'( OO  " "  ! ! NN    LL KK MM   OO  OO        ! !  % ( n % OO  " "  ! ! NN    LL KK MM   OO         ! $ j ! OO  " "  ! ! NN       LL LL KK MM  OO     MM         OO OO+ 4 OO  " "  ! ! NN    LL KK MM   OO     MM  ! $ >>4 r)cp |jt|jffS#t$r tdfcYSwxYw)z@Cell (containing values of a function's free variables) reducer.r/)rrrrrs r _cell_reducerXsB0 C--/// $##$s !55c6|j}t||ffSr )__func__rM)r> orig_funcs r_classmethod_reducer\s I 9yl ""r)cddl}t|dr t|dstjd|tj urt tdffS|tjurt tdffS|tjurtjd|jrtjd t|d r%|jrtjd d |jvr0d |jvr"tjd|jz|j}|j} |j}|jd|j!}|j||j%||j|||_ t&|ffS#t"$r}tjd|z|d}~wwxYw)z Save a file.rNr?modez5Cannot pickle files that do not map to an actual filestdoutstderrzCannot pickle standard inputzCannot pickle closed filesisattyz+Cannot pickle files that map to tty objectsr+z7Cannot pickle files that are not opened for reading: %sz*Cannot pickle file %s as it cannot be read)iorcpickle PicklingErrorr"r_rEr`stdinclosedrar^r?StringIOtellseekreadOSErrorwriter )r>rdr?r curloccontentsrs r _file_reducerqs 3 wsF';"" C   cjjh'' cjjh'' cii""#ABB zz""#?@@sH#**,""#PQQ #((s#((2"" E P   88D R[[]F   88:   LL KKFK  )) "" 84 ?  sAF;; G"GG"c>t|j|jffSr )rE __objclass__r!rs r_getset_descriptor_reducerts S%%s||4 44r)c:tjt|ffSr )rMappingProxyTyperrs r_mappingproxy_reducerws  ! !DI< //r)c0t|jffSr )bytestobytesrs r_memoryview_reducer{s 3;;=" ""r)ct|rt|jffS|jj }|j ddt |j|ffSr)rRrr!rr.rr)r>rs r_module_reducer}sQ"3'3<rr obj_globals obj_closurerrrrrs r_function_setstaterdsE9LL-- .K-- .K MM+,OO;'&2COON# - 5GAt **05COOA  ,  5!1Q   s C C*)C*c|\}}d}|jD]\}}|dk(r|}t|||tjdk\rd|vr |d|_||D]}|j ||S)Nr")r8 __firstlineno__)rFrr" version_inforregister)r>rrr'r1attrsubclasss rrrsE9H++-)$ { "H C4 (!)$ 7"'8E'A$$56  #H LL " # Jr)ct|Sr ) _DATACLASSE_FIELD_TYPE_SENTINELSrJs rrrs +D 11r)c6eZdZiZeee<eeej<e ee j<e ee j<eee<eee<eee<eee<eeej.<eeej2<eeej6<eeej:<eeej><e ee!jD<e#ee$jJ<e&ee'jP<e)ee'jT<e+ee'jX<e-ee.e/ja<e1ee.e/je<e3ee.e/ji<eee5jl<eee5jn<eee5jp<eee5jr<e:ee;jx<e=ee>j~Z?dZ@dZAdZBfdZCd fd ZDeEs e?ZFdZGxZRSeHjjjZF d dZKdeLjffd ZNeNeFe.<dfd ZOd ZPeOeFej<xZRS)PicklercZ|j|}t|}t||ddtfS)z>Reduce a function that is not pickleable via attribute lookup.N)_function_getnewargsrrr)selfrnewargsrs r_dynamic_function_reducez Pickler._dynamic_function_reduces0++D1"4(ds r_function_reducezPickler._function_reduces# 's +! !005 5r)cZ|j}|jjt|ji}|ik(r(dD]#}||jvs|j|||<%|j d}n.t dtt|jD}||dd|fS)N)rbr!__path____file__c30K|]}tywr )r)rrs rrz/Pickler._function_getnewargs..sU1,.Us) r globals_refridrrr@rangergrB)rrrj base_globalsrrs rrzPickler._function_getnewargss}}''222d6F6F3GL 2 I :(((&*&6&6q&9LO :    #GUc$BRBR>S8TUUG\4w66r)c t||S#t$rG}t|jdkDr)d|jdvrd}t j ||d}~wwxYw)Nr recursionz?Could not pickle object as excessively deep recursion required.)superdump RuntimeErrorrgrUrerf)rr>rmsgrs rrz Pickler.dumps` 7<$ $ 166{Q;!&&)#;W**3/Q6  s A"AAA"Nch|t}t| |||i|_t ||_y)Nprotocolbuffer_callback)DEFAULT_PROTOCOLr__init__rintproto)rfilerrrs rrzPickler.__init__s7  'H /R] r)ct|} t|t}|r t|St |t j r|j|StS#t$rd}YKwxYw)a=Type-agnostic reducing callback for function and classes. For performance reasons, subclasses of the C `pickle.Pickler` class cannot register custom reducers for functions and classes in the dispatch_table attribute. Reducers for such types must instead implemented via the special `reducer_override` method. Note that this method will be called for any object except a few builtin-types (int, lists, dicts etc.), which differs from reducers in the Pickler's dispatch_table, each of them being invoked for objects of a specific type only. This property comes in handy for classes: although most classes are instances of the ``type`` metaclass, some of them can be instances of other custom metaclasses (such as enum.EnumMeta for example). In particular, the metaclass will likely not be known in advance, and thus cannot be special-cased using an entry in the dispatch_table. reducer_override, among other things, allows us to register a reducer that will be called for any class, independently of its type. Notes: * reducer_override has the priority over dispatch_table-registered reducers. * reducer_override can be used to fix other limitations of cloudpickle for other types that suffered from type-specific reducers, such as Exceptions. See https://github.com/cloudpipe/cloudpickle/issues/248 F) rMrLrOrrrrKrr)rr>t is_anyclasss rreducer_overridezPickler.reducer_overrideDsm>S A $(D1 $S))C!3!34,,S11&% $#  $sA A)(A)c|j}|j} |j||d|||||||||| tj| tj | tj y)N)r listitems dictitemsr>)savern save_reducereTUPLE2REDUCEPOP) rrrUrrr state_setterr>rrns r_save_reduce_pickle5zPickler._save_reduce_pickle5ysy99DJJE   ##     I K &-- &-- &** r)c|tdur|jtd|S|ttur|jttf|S|ttur|jttf|S|tvr |jt t|f|S|t |||yt||s|jt|d|iyt |||y)zMain dispatch method. The name of this method is somewhat misleading: all types get dispatched here. Nr rrJr>) rMrrrrrvr save_globalrRrr)rr>r?packrs rrzPickler.save_globals d4j ''g3'??X&''xks'CC^,,''~.?S'II++''!$7$<#>C(#Cd#304@)))+@+EO3O#Cd#3r)ct||rt| ||Str+t |j t r|j|S|j|j|d|iS)zRegistered with the dispatch to handle all function types. Determines what kind of function obj is (e.g. lambda, defined at interactive prompt, etc) and handles the pickling appropriately. rJr>) rRrrPYPYrrbuiltin_code_typesave_pypy_builtin_funcrr)rr>r?rs r save_functionzPickler.save_functionsq +3T:w*3T*::*S\\3DE223770t002237=@r)ctj|ji|j|j|j f|j f}|j|d|iy)a Save pypy equivalent of builtin functions. PyPy does not have the concept of builtin-functions. Instead, builtin-functions are simple function instances, but with a builtin-code attribute. Most of the time, builtin functions should be pickled by attribute. But PyPy has flaky support for __qualname__, so some builtin functions such as float.__new__ will be classified as dynamic. For this reason only, we created this special routine. Because builtin-functions are not expected to have closure or globals, there is no additional hack (compared the one already implemented in pickle) to protect ourselves from reference cycles. A simple (reconstructor, newargs, obj.__dict__) tuple is save_reduced. Note also that PyPy improved their support for __qualname__ in v3.6, so this routing should be removed when cloudpickle supports only PyPy 3.6 and later. r>N)rrKrr!rrrr)rr>rvs rrzPickler.save_pypy_builtin_funcsR&""r3<<1A1A3??S B D  b *c *r)NN)NNNNNr )Sr!rBrT_dispatch_tabler\rrqrd TextIOWrapperrrLoggerr RootLoggerr{ memoryviewrr staticmethodrXrrVrr[rtGetSetDescriptorTyper}rrrrwrvrrrrrrr_collections_abc dict_keysr dict_valuesr dict_itemsrrMrrrrrrFr$abstractmethodabstractclassmethodabstractstaticmethodabstractpropertyr dataclasses _FIELD_BASErcopyregdispatch_tablerrrrrrdispatchrrerr.rstructrrrrrK __classcell__)rs@rrrsJO#6OK (4OB$$%&4OGNN#*=OG&&'"4OJ 0OH$7OL! ,OH&2OENN#2KOE../(6OE$$%(6OE$$%.BOE**+'6OGOO$&5OFNN#2CO$../4GO$0013EO$//02DOD++-./4HOD--/013FOD,,./0*=OC&&'/BOC++,0COC,,-,>**//1  B)-6;; 40%  +2(5##$r)rc>t|||j|y)a+Serialize obj as bytes streamed into file protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to pickle.HIGHEST_PROTOCOL. This setting favors maximum communication speed between processes running the same Python version. Set protocol=pickle.DEFAULT_PROTOCOL instead if you need to ensure compatibility with older versions of Python (although this is not always guaranteed to work because cloudpickle relies on some internal implementation details that can change from one Python version to the next). rN)rr)r>rrrs rrrs D8_EJJ3Or)ctj5}t|||}|j||j cdddS#1swYyxYw)a8Serialize obj as a string of bytes allocated in memory protocol defaults to cloudpickle.DEFAULT_PROTOCOL which is an alias to pickle.HIGHEST_PROTOCOL. This setting favors maximum communication speed between processes running the same Python version. Set protocol=pickle.DEFAULT_PROTOCOL instead if you need to ensure compatibility with older versions of Python (although this is not always guaranteed to work because cloudpickle relies on some internal implementation details that can change from one Python version to the next). rN)rdBytesIOrrgetvalue)r>rrrcps rdumpsrsF  THo N  }}s /AAr )Fr)rr collectionsrrr$rrrrxenumrrdrrrzrerr;platformrr" threadingrrrrrrHIGHEST_PROTOCOLrrfr$WeakKeyDictionaryr WeakValueDictionaryrLockr python_implementationrrrMfloatrrrXrrr(r,r0r7rrHrRrNr]rpopmaprqrrrsr{ HAVE_ARGUMENT EXTENDED_ARGrrrFrrrvrYrrrrrrrrrrrrrrrrrrrrrr rr*r3rVrXr\rqrtrwr{r}rrrrrrrrrrrrrrrr_FIELDr?_FIELD_CLASSVAR_FIELD_INITVARrrrrrloadloads CloudPicklerr/r)rr"sz2h-    8    **5 #<'";";"=:w::<,inn.%x%%'61U]]3347g779$2N9+ w:2D! H%P2.d||N+  _- ll=) M; 7 !!   NN "#DAq Aw$!"A#  2+(!    E )'D2@>8 & $):& (V$N@l ^0# )*X50# 8<*!A) 6 )+*.0/;D#\[//$$k&A&A##[%?%?$ 2^5fnn^5H P (kk6<< e r)