6Isphinx.addnodesdocument)}( rawsourcechildren]docutils.nodessection)}(hhh](h title)}(h!The main differences with CPythonh]h Text!The main differences with CPython}(hhparenthhhsourceNlineNuba attributes}(ids]classes]names]dupnames]backrefs]utagnamehhh hhh\/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/docs/sphinx/differences_cpython.rsthKubh )}(hhh](h)}(hMDifferences due to the compiled, rather than interpreted nature of Transcrypth]hMDifferences due to the compiled, rather than interpreted nature of Transcrypt}(hh1hh/hhhNhNubah}(h ]h"]h$]h&]h(]uh*hhh,hhhh+hKubh bullet_list)}(hhh](h list_item)}(hSince Transcrypt is precompiled on the development machine, Python's exec and eval are not supported, but JavaScript's eval is.h]h paragraph)}(hhFh]hSince Transcrypt is precompiled on the development machine, Python’s exec and eval are not supported, but JavaScript’s eval is.}(hhFhhJubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhhDubah}(h ]h"]h$]h&]h(]uh*hBhh?hhhh+hNubhC)}(hUC++ style conditional compilation is supported through :ref:`pragmas `.h]hI)}(hh_h](h7C++ style conditional compilation is supported through }(h7C++ style conditional compilation is supported through hhaubh pending_xref)}(h:ref:`pragmas `h]h inline)}(hhmh]hpragmas}(hhhhqubah}(h ]h"](xrefstdstd-refeh$]h&]h(]uh*hohhkubah}(h ]h"]h$]h&]h(]refdocdifferences_cpython refdomainh|reftyperef refexplicitrefwarn reftarget pragma_ifdefuh*hihh+hKhhaubh.}(h.hhaubeh}(h ]h"]h$]h&]h(]uh*hHhh+hKhh]ubah}(h ]h"]h$]h&]h(]uh*hBhh?hhhh+hNubhC)}(hjConditional import of modules is done by using conditional compilation rather than conditional statements.h]hI)}(hhh]hjConditional import of modules is done by using conditional compilation rather than conditional statements.}(hhhhubah}(h ]h"]h$]h&]h(]uh*hHhh+hK hhubah}(h ]h"]h$]h&]h(]uh*hBhh?hhhh+hNubhC)}(hQSource level debugging in the browser is available through the use of sourcemaps.h]hI)}(hhh]hQSource level debugging in the browser is available through the use of sourcemaps.}(hhhhubah}(h ]h"]h$]h&]h(]uh*hHhh+hK hhubah}(h ]h"]h$]h&]h(]uh*hBhh?hhhh+hNubhC)}(hRunning a compiled Transcrypt program doesn't require a Python or Transcrypt interpreter. It only requires the runtime, which is about 40 kB. h]hI)}(hRunning a compiled Transcrypt program doesn't require a Python or Transcrypt interpreter. It only requires the runtime, which is about 40 kB.h]hRunning a compiled Transcrypt program doesn’t require a Python or Transcrypt interpreter. It only requires the runtime, which is about 40 kB.}(hhhhubah}(h ]h"]h$]h&]h(]uh*hHhh+hK hhubah}(h ]h"]h$]h&]h(]uh*hBhh?hhhh+hNubeh}(h ]h"]h$]h&]h(]bullet-uh*h=hh+hKhh,hhubeh}(h ]Ldifferences-due-to-the-compiled-rather-than-interpreted-nature-of-transcryptah"]h$]Mdifferences due to the compiled, rather than interpreted nature of transcryptah&]h(]uh*h hh hhhh+hKubh )}(hhh](h)}(h2Differences due to the 'lean and mean' design goalh]h6Differences due to the ‘lean and mean’ design goal}(hhhhhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhhhhhh+hKubh>)}(hhh](hC)}(hFacilities like operator overloading, automatic truth value conversion and named parameters can be switched on and off locally using pragmas, to keep the generated code small.h]hI)}(hj h]hFacilities like operator overloading, automatic truth value conversion and named parameters can be switched on and off locally using pragmas, to keep the generated code small.}(hj hjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhj ubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hzInterpreting negative indices as offsets from the end of a list or string requires operator overloading to be switched on.h]hI)}(hj$h]hzInterpreting negative indices as offsets from the end of a list or string requires operator overloading to be switched on.}(hj$hj&ubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhj"ubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hString formatting is done through the *format* method or through f-strings, as this is considered most flexible. Using % for formatting isn't supported.h]hI)}(hj;h](h&String formatting is done through the }(h&String formatting is done through the hj=ubh emphasis)}(h*format*h]hformat}(hhhjGubah}(h ]h"]h$]h&]h(]uh*jEhj=ubhl method or through f-strings, as this is considered most flexible. Using % for formatting isn’t supported.}(hj method or through f-strings, as this is considered most flexible. Using % for formatting isn't supported.hj=ubeh}(h ]h"]h$]h&]h(]uh*hHhh+hKhj9ubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hSome methods of container types like list, set and dict, that duplicate functionality of other methods, have been left out of the core libraries. If needed they can be supplied in separate libraries.h]hI)}(hjhh]hSome methods of container types like list, set and dict, that duplicate functionality of other methods, have been left out of the core libraries. If needed they can be supplied in separate libraries.}(hjhhjjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhjfubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hWMetaclasses only support overloading the __new__ method, covering 90% of the use cases.h]hI)}(hjh]hWMetaclasses only support overloading the __new__ method, covering 90% of the use cases.}(hjhjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhj}ubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hCurrently the \*, /, //, +, -, @, [], (), ==, !=, <, <=, >, >=, \*\*, << and >> operators can be overloaded, both forward and reverse where appropriate, covering almost all usecases.h]hI)}(hjh]hCurrently the *, /, //, +, -, @, [], (), ==, !=, <, <=, >, >=, **, << and >> operators can be overloaded, both forward and reverse where appropriate, covering almost all usecases.}(hCurrently the \*, /, //, +, -, @, [], (), ==, !=, <, <=, >, >=, \*\*, << and >> operators can be overloaded, both forward and reverse where appropriate, covering almost all usecases.hjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hGThe 'with' statement can currently only be used for file-like objects. h]hI)}(hFThe 'with' statement can currently only be used for file-like objects.h]hJThe ‘with’ statement can currently only be used for file-like objects.}(hjhjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubeh}(h ]h"]h$]h&]h(]hhuh*h=hh+hKhhhhubeh}(h ]0differences-due-to-the-lean-and-mean-design-goalah"]h$]2differences due to the 'lean and mean' design goalah&]h(]uh*h hh hhhh+hKubh )}(hhh](h)}(hLDifferences due to interoperability with JavaScript and JavaScript librariesh]hLDifferences due to interoperability with JavaScript and JavaScript libraries}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hKubh>)}(hhh](hC)}(h~Python objects, functions and methods and their JavaScript counterparts can in general be mixed freely without special syntax.h]hI)}(hjh]h~Python objects, functions and methods and their JavaScript counterparts can in general be mixed freely without special syntax.}(hjhjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hTo be able to use JSON-like syntax in configuring JavaScript libraries, Transcrypt dicts are in fact JavaScript objects. Attribute keys that may denote a number are interpreted as such, all others are interpreted as strings.h]hI)}(hjh]hTo be able to use JSON-like syntax in configuring JavaScript libraries, Transcrypt dicts are in fact JavaScript objects. Attribute keys that may denote a number are interpreted as such, all others are interpreted as strings.}(hjhjubah}(h ]h"]h$]h&]h(]uh*hHhh+hKhjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hAny amount of literal JavaScript can be included in-line or from a separate file using :ref:`\_\_pragma\_\_ ('js', ..., ...) `.h]hI)}(hjh](hWAny amount of literal JavaScript can be included in-line or from a separate file using }(hWAny amount of literal JavaScript can be included in-line or from a separate file using hjubhj)}(h2:ref:`\_\_pragma\_\_ ('js', ..., ...) `h]hp)}(hj"h]h__pragma__ (‘js’, …, …)}(hhhj$ubah}(h ]h"](h{stdstd-refeh$]h&]h(]uh*hohj ubah}(h ]h"]h$]h&]h(]refdoch refdomainj.reftyperef refexplicitrefwarnh pragma_jsuh*hihh+hKhjubh.}(hhhjubeh}(h ]h"]h$]h&]h(]uh*hHhh+hKhjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hUThe *print* function can be used to print to a DOM element or to the browser console.h]hI)}(hjRh](hThe }(hThe hjTubjF)}(h*print*h]hprint}(hhhj\ubah}(h ]h"]h$]h&]h(]uh*jEhjTubhJ function can be used to print to a DOM element or to the browser console.}(hJ function can be used to print to a DOM element or to the browser console.hjTubeh}(h ]h"]h$]h&]h(]uh*hHhh+hKhjPubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hThe methods *console.dir* and *console.log* are also available when programming for the browser, as are in fact all JavaScript facilities, including the complete DOM-manipulation API.h]hI)}(hj}h](h The methods }(h The methods hjubjF)}(h *console.dir*h]h console.dir}(hhhjubah}(h ]h"]h$]h&]h(]uh*jEhjubh and }(h and hjubjF)}(h *console.log*h]h console.log}(hhhjubah}(h ]h"]h$]h&]h(]uh*jEhjubh are also available when programming for the browser, as are in fact all JavaScript facilities, including the complete DOM-manipulation API.}(h are also available when programming for the browser, as are in fact all JavaScript facilities, including the complete DOM-manipulation API.hjubeh}(h ]h"]h$]h&]h(]uh*hHhh+hKhj{ubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hXCertain identifiers are reserved in JavaScript. In most cases they still can be used in Transcrypt, since they are aliased to other identifiers. Identifiers and directory keys starting with *py\_* are to be avoided, since many of them have special meaning in Transcrypt. It would have been possible to make clashes even more rare, by using e.g. @ and \_\_ in but this would have made the JavaScript code harder to read. Note that you can define a local alias yourself if you still want to use a reserved identifier.h]hI)}(hjh](hCertain identifiers are reserved in JavaScript. In most cases they still can be used in Transcrypt, since they are aliased to other identifiers. Identifiers and directory keys starting with }(hCertain identifiers are reserved in JavaScript. In most cases they still can be used in Transcrypt, since they are aliased to other identifiers. Identifiers and directory keys starting with hjubjF)}(h*py\_*h]hpy_}(hhhjubah}(h ]h"]h$]h&]h(]uh*jEhjubhX? are to be avoided, since many of them have special meaning in Transcrypt. It would have been possible to make clashes even more rare, by using e.g. @ and __ in but this would have made the JavaScript code harder to read. Note that you can define a local alias yourself if you still want to use a reserved identifier.}(hX? are to be avoided, since many of them have special meaning in Transcrypt. It would have been possible to make clashes even more rare, by using e.g. @ and \_\_ in but this would have made the JavaScript code harder to read. Note that you can define a local alias yourself if you still want to use a reserved identifier.hjubeh}(h ]h"]h$]h&]h(]uh*hHhh+hK hjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(h9The name *type* cannot be used as an ordinary identifier.h]hI)}(hjh](h The name }(h The name hjubjF)}(h*type*h]htype}(hhhjubah}(h ]h"]h$]h&]h(]uh*jEhjubh* cannot be used as an ordinary identifier.}(h* cannot be used as an ordinary identifier.hjubeh}(h ]h"]h$]h&]h(]uh*hHhh+hK!hjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubhC)}(hoYou can use *require* to load JavaScript modules on the fly and access them just as you would from JavaScript. h]hI)}(hnYou can use *require* to load JavaScript modules on the fly and access them just as you would from JavaScript.h](h You can use }(h You can use hjubjF)}(h *require*h]hrequire}(hhhjubah}(h ]h"]h$]h&]h(]uh*jEhjubhY to load JavaScript modules on the fly and access them just as you would from JavaScript.}(hY to load JavaScript modules on the fly and access them just as you would from JavaScript.hjubeh}(h ]h"]h$]h&]h(]uh*hHhh+hK"hjubah}(h ]h"]h$]h&]h(]uh*hBhjhhhh+hNubeh}(h ]h"]h$]h&]h(]hhuh*h=hh+hKhjhhubeh}(h ]Ldifferences-due-to-interoperability-with-javascript-and-javascript-librariesah"]h$]Ldifferences due to interoperability with javascript and javascript librariesah&]h(]uh*h hh hhhh+hKubh )}(hhh](h)}(h]Differences due to running Transcrypt applications in the browser, rather than on the desktoph]h]Differences due to running Transcrypt applications in the browser, rather than on the desktop}(hjNhjLhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjIhhhh+hK%ubh>)}(hhh](hC)}(hTranscrypt doesn't directly support the use of libraries written in C or C++ since, without special measures like compiling to asm.js, C and C++ don't run in the browser.h]hI)}(hj_h]hTranscrypt doesn’t directly support the use of libraries written in C or C++ since, without special measures like compiling to asm.js, C and C++ don’t run in the browser.}(hj_hjaubah}(h ]h"]h$]h&]h(]uh*hHhh+hK'hj]ubah}(h ]h"]h$]h&]h(]uh*hBhjZhhhh+hNubhC)}(h|The browser programming model is event driven, so Transcrypt programs are even driven, as are their JavaScript counterparts.h]hI)}(hjvh]h|The browser programming model is event driven, so Transcrypt programs are even driven, as are their JavaScript counterparts.}(hjvhjxubah}(h ]h"]h$]h&]h(]uh*hHhh+hK(hjtubah}(h ]h"]h$]h&]h(]uh*hBhjZhhhh+hNubhC)}(hJust like JavaScript, Transcrypt running in the browser cannot write to an ordinary disk file, due to security limitations. However, just like JavaScript, it can store and retrieve data using JSON and Ajax. h]hI)}(hJust like JavaScript, Transcrypt running in the browser cannot write to an ordinary disk file, due to security limitations. However, just like JavaScript, it can store and retrieve data using JSON and Ajax.h]hJust like JavaScript, Transcrypt running in the browser cannot write to an ordinary disk file, due to security limitations. However, just like JavaScript, it can store and retrieve data using JSON and Ajax.}(hjhjubah}(h ]h"]h$]h&]h(]uh*hHhh+hK)hjubah}(h ]h"]h$]h&]h(]uh*hBhjZhhhh+hNubeh}(h ]h"]h$]h&]h(]hhuh*h=hh+hK'hjIhhubeh}(h ]\differences-due-to-running-transcrypt-applications-in-the-browser-rather-than-on-the-desktopah"]h$]]differences due to running transcrypt applications in the browser, rather than on the desktopah&]h(]uh*h hh hhhh+hK%ubeh}(h ]!the-main-differences-with-cpythonah"]h$]!the main differences with cpythonah&]h(]uh*h hhhhhh+hKubah}(h ]h"]h$]h&]h(]sourceh+uh*hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh+ _destinationN _config_files]pep_referencesN pep_base_url https://www.python.org/dev/peps/pep_file_url_templatepep-%04drfc_referencesN rfc_base_urlhttps://tools.ietf.org/html/ tab_widthKtrim_footnote_reference_spacefile_insertion_enabled raw_enabledKsyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xformembed_stylesheetcloak_email_addressesenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjhhjjjFjCjju nametypes}(jNhNjNjFNjNuh }(jh hh,jhjCjjjIu footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN decorationNhhub.