• Guest
HabraHabr
  • Main
  • Users

  • Development
    • Programming
    • Information Security
    • Website development
    • JavaScript
    • Game development
    • Open source
    • Developed for Android
    • Machine learning
    • Abnormal programming
    • Java
    • Python
    • Development of mobile applications
    • Analysis and design of systems
    • .NET
    • Mathematics
    • Algorithms
    • C#
    • System Programming
    • C++
    • C
    • Go
    • PHP
    • Reverse engineering
    • Assembler
    • Development under Linux
    • Big Data
    • Rust
    • Cryptography
    • Entertaining problems
    • Testing of IT systems
    • Testing Web Services
    • HTML
    • Programming microcontrollers
    • API
    • High performance
    • Developed for iOS
    • CSS
    • Industrial Programming
    • Development under Windows
    • Image processing
    • Compilers
    • FPGA
    • Professional literature
    • OpenStreetMap
    • Google Chrome
    • Data Mining
    • PostgreSQL
    • Development of robotics
    • Visualization of data
    • Angular
    • ReactJS
    • Search technologies
    • Debugging
    • Test mobile applications
    • Browsers
    • Designing and refactoring
    • IT Standards
    • Solidity
    • Node.JS
    • Git
    • LaTeX
    • SQL
    • Haskell
    • Unreal Engine
    • Unity3D
    • Development for the Internet of things
    • Functional Programming
    • Amazon Web Services
    • Google Cloud Platform
    • Development under AR and VR
    • Assembly systems
    • Version control systems
    • Kotlin
    • R
    • CAD/CAM
    • Customer Optimization
    • Development of communication systems
    • Microsoft Azure
    • Perfect code
    • Atlassian
    • Visual Studio
    • NoSQL
    • Yii
    • Mono и Moonlight
    • Parallel Programming
    • Asterisk
    • Yandex API
    • WordPress
    • Sports programming
    • Lua
    • Microsoft SQL Server
    • Payment systems
    • TypeScript
    • Scala
    • Google API
    • Development of data transmission systems
    • XML
    • Regular expressions
    • Development under Tizen
    • Swift
    • MySQL
    • Geoinformation services
    • Global Positioning Systems
    • Qt
    • Dart
    • Django
    • Development for Office 365
    • Erlang/OTP
    • GPGPU
    • Eclipse
    • Maps API
    • Testing games
    • Browser Extensions
    • 1C-Bitrix
    • Development under e-commerce
    • Xamarin
    • Xcode
    • Development under Windows Phone
    • Semantics
    • CMS
    • VueJS
    • GitHub
    • Open data
    • Sphinx
    • Ruby on Rails
    • Ruby
    • Symfony
    • Drupal
    • Messaging Systems
    • CTF
    • SaaS / S+S
    • SharePoint
    • jQuery
    • Puppet
    • Firefox
    • Elm
    • MODX
    • Billing systems
    • Graphical shells
    • Kodobred
    • MongoDB
    • SCADA
    • Hadoop
    • Gradle
    • Clojure
    • F#
    • CoffeeScript
    • Matlab
    • Phalcon
    • Development under Sailfish OS
    • Magento
    • Elixir/Phoenix
    • Microsoft Edge
    • Layout of letters
    • Development for OS X
    • Forth
    • Smalltalk
    • Julia
    • Laravel
    • WebGL
    • Meteor.JS
    • Firebird/Interbase
    • SQLite
    • D
    • Mesh-networks
    • I2P
    • Derby.js
    • Emacs
    • Development under Bada
    • Mercurial
    • UML Design
    • Objective C
    • Fortran
    • Cocoa
    • Cobol
    • Apache Flex
    • Action Script
    • Joomla
    • IIS
    • Twitter API
    • Vkontakte API
    • Facebook API
    • Microsoft Access
    • PDF
    • Prolog
    • GTK+
    • LabVIEW
    • Brainfuck
    • Cubrid
    • Canvas
    • Doctrine ORM
    • Google App Engine
    • Twisted
    • XSLT
    • TDD
    • Small Basic
    • Kohana
    • Development for Java ME
    • LiveStreet
    • MooTools
    • Adobe Flash
    • GreaseMonkey
    • INFOLUST
    • Groovy & Grails
    • Lisp
    • Delphi
    • Zend Framework
    • ExtJS / Sencha Library
    • Internet Explorer
    • CodeIgniter
    • Silverlight
    • Google Web Toolkit
    • CakePHP
    • Safari
    • Opera
    • Microformats
    • Ajax
    • VIM
  • Administration
    • System administration
    • IT Infrastructure
    • *nix
    • Network technologies
    • DevOps
    • Server Administration
    • Cloud computing
    • Configuring Linux
    • Wireless technologies
    • Virtualization
    • Hosting
    • Data storage
    • Decentralized networks
    • Database Administration
    • Data Warehousing
    • Communication standards
    • PowerShell
    • Backup
    • Cisco
    • Nginx
    • Antivirus protection
    • DNS
    • Server Optimization
    • Data recovery
    • Apache
    • Spam and antispam
    • Data Compression
    • SAN
    • IPv6
    • Fidonet
    • IPTV
    • Shells
    • Administering domain names
  • Design
    • Interfaces
    • Web design
    • Working with sound
    • Usability
    • Graphic design
    • Design Games
    • Mobile App Design
    • Working with 3D-graphics
    • Typography
    • Working with video
    • Work with vector graphics
    • Accessibility
    • Prototyping
    • CGI (graphics)
    • Computer Animation
    • Working with icons
  • Control
    • Careers in the IT industry
    • Project management
    • Development Management
    • Personnel Management
    • Product Management
    • Start-up development
    • Managing the community
    • Service Desk
    • GTD
    • IT Terminology
    • Agile
    • Business Models
    • Legislation and IT-business
    • Sales management
    • CRM-systems
    • Product localization
    • ECM / EDS
    • Freelance
    • Venture investments
    • ERP-systems
    • Help Desk Software
    • Media management
    • Patenting
    • E-commerce management
    • Creative Commons
  • Marketing
    • Conferences
    • Promotion of games
    • Internet Marketing
    • Search Engine Optimization
    • Web Analytics
    • Monetize Web services
    • Content marketing
    • Monetization of IT systems
    • Monetize mobile apps
    • Mobile App Analytics
    • Growth Hacking
    • Branding
    • Monetize Games
    • Display ads
    • Contextual advertising
    • Increase Conversion Rate
  • Sundry
    • Reading room
    • Educational process in IT
    • Research and forecasts in IT
    • Finance in IT
    • Hakatonas
    • IT emigration
    • Education abroad
    • Lumber room
    • I'm on my way

Python transpiler chain → 11l → C ++[для ускорения Python-кода и не только]

3r33800.  3r33818. Python transpiler chain → 11l → C ++[для ускорения Python-кода и не только] 3r3r6806. 3r33800.  3r33818.

Replacing the "slices" slices on the ranks ranges


 3r33818.
 3r33818. 3r3804. Python 3r3807.  3r33818. 3r3804. 11l 3r3807.  3r33818. 3r3809.  3r33818.
 3r33818. 3r3804. 3r3667. 3r3658. s[-1]3r33818. s[-2]3r33818. s[:-1]3r33818. s[1:]3r33818. s[:1:]3r33818. s[1:2]3r33818. s[::2]3r33818. s[3:10:2]3r33818. s[3:10:]3r33818. 3r3673.
 3r33818. 3r3804. 3r3667. 3r3658. s.last
s[(len)-2]3r33818. s[0<(len)-1]3r33818. s[1]3r33818. s[0<1]3r33818. s[1<2]3r33818. s[(0).step(2)]3r33818. s[(3<10).step(2)]3r33818. s[3<10]3r33818. 3r3673.
 3r33818. 3r3809.  3r33818. 3r33811. Explicit indication for indexing from the end of the array s[(len)-2]3r3673. instead of just 3r3638. s[-2]3r3673. needed to eliminate the following errors: 3r30000.  3r33818.  3r33818. When you want for example to get the previous character on 3r3638. s[i-1]3r3673. , but if i = ? this /this record instead of an error will silently return the last character of the string [и я на практике сталкивался с такой ошибкой — коммит]3r3772. .  3r33818. Expression 3r3638. s[i:]3r3673. after 3r3638. i = s.find (":") will work incorrectly when the character is not found in line [вместо ‘‘часть строки начиная с первого символа : и далее’’ будет взят последний символ строки]3r3772. (and generally, return 3r3633. -1 function 3r3638. find () 3r3672. In Python, I consider it also wrong 3r3771.[следует возвращать null/None [а если требуется -1, то следует писать явно: i = s.find(":") ?? -1]3rr77772. 3r3771.  3r33818. Record 3r3638. s[-n:]3r3673. for 3r3638. n the last characters of the string will not work correctly when n = 0.  3r33818. 3r33800.  3r33818.

Chains of comparison operators

3r33800.  3r33818. At first glance, it’s an outstanding feature of the Python language, but in practice it can easily be discarded /dispensed with by the operator 3r3638. in and ranges: 3r30000.  3r33818.
  1.  3r33818.
  2. 3r337. 3r33737. In all places where I met Python's list comprehension, you can easily get away with the functions `filter ()` and `map ()`. 3r33712. 3r33737. 3r3667. 3r3658. dirs[:]=[d for d in dirs if d[0]! = '.' and d! = exclude_dir]
    dirs[:]= filter (lambda d: d[0]! = '.' and d! = exclude_dir, dirs)
    3r33818. '[' + ', '.join(python_types_to_11l[ty]for ty in self.type_args) + ']'
    '[' + ', '.join(map(lambda ty: python_types_to_11l[ty], self.type_args)) + ']'
    3r33818. # Nested list comprehension:
    matrix =[
    [1, 2, 3, 4], 3r33818.[5, 6, 7, 8], 3r33818.[9, 10, 11, 12], 3r33818. ]3r33818.[[row[i]for row in matrix]for i in range (4)]
    list (map (lambda i: list (map (lambda row: row[i], matrix)), range (4)))
    3r3673. 3r33838. 3r33838.  3r33818.
  3. 3r337. 3r33737. `filter ()` and `map ()` in 11l look prettier than in Python [/b] 3r33737. 3r3667. 3r3668. dirs[:]= filter (lambda d: d[0]! = '.' and d! = exclude_dir, dirs)
    dirs = dirs.filter (d -> d[0]! = ‘.’ & d! = @ exclude_dir)
    3r33818. '[' + ', '.join(map(lambda ty: python_types_to_11l[ty], self.type_args)) + ']'
    ‘W2w2w241. ) .join (‘,’)) ‘]’ 3r3-3818. 3r33818. outfile.write ("n" .join (x[1]for x in fileslist if x[0]))
    outfile.write ("n" .join (map (lambda x: x[1], filter (lambda x: x[0], fileslist))))
    outfile.write (fileslist.filter (x -> x[0]) .map (x -> x[1]) .join ("n"))
    3r3673. 3r33838. 3r33838. and therefore the need for list comprehensions in 11l actually disappears [замена list comprehension на filter() и/или map() выполняется в процессе преобразования Python-кода в 11l автоматически]3r3772. .  3r33818.
3r33800.  3r33818.

Convert the if-elif-else chain to switch

3r33800.  3r33818. While Python does not contain a switch statement, this is one of the most beautiful constructions in the 11l language, and so I decided to insert the switch automatically:
 3r33818. с точки зрения производительности]3r3772. but it is very convenient. 3r33800.  3r33818. 3r33800.  3r33818. In 11l, the same line corresponding to this line is 3r3771.[и полученная транспайлером Python → 11l]3r3772. Record not only comfortable [впрочем, не настолько изящная как в Python]3r3772. , but also fast:
 3r33818. 3r3667. 3r3668. var tag = switch prev_char () {‘*’ {‘b’}; ‘_’ {‘U’}; ‘-’ {‘s’}; ‘~’ {‘I’}} 3-333818. 3r3673. 3r33800.  3r33818. The above line is shipped to: 3r30000.  3r33818. 3r3667. 3r3668. auto tag =[&](const auto & a) {return a == u '*'? u'b'_C: a == u'_ '? u'u'_C: a == u'- '? u's'_C: a == u '~'? u'i'_C: throw KeyError (a);} (prev_char ()); 3r33818. 3r3673. [Вызов лямбда-функции компилятор C++ встроитinline в процессе оптимизации и останется только цепочка операторов ?/:.]3r3772. 3r33800.  3r33818. 3r33800.  3r33818. In the case when assignment is made to a variable, the dictionary is left as it is: 3r30000.  3r33818.

Capture Ca pture of external variables [/h3] 3r33800.  3r33818. In Python, to indicate that a variable is not local, but must be taken outside [от текущей функции]3r3772. , the keyword nonlocal is used.[в противном случае к примеру found = True будет трактоваться как создание новой локальной переменной found, а не присваивание значения уже существующей внешней переменной]3r3772. . 3r33800.  3r33818. In 11l, the prefix @: 3r33800 is used for this.  3r33818.

[посредством ключевого слова global]3r3772. , then you get an inconspicuous bug:
 3r33818.
[справа]3r3772. unlike python [слева]3r3772. will generate an error at compile time ‘undeclared variable break_label_index ’. 3r33800.  3r33818. 3r33800.  3r33818.

The index /number of the current item in the

container. 3r33800.  3r33818. I always forget the order of the variables that the Python function returns enumerate {first comes the value, and then the index or vice versa}. Similar behavior in Ruby - 3r3638. each.with_index - it is much easier to remember: with index means that index comes after value, and not before. But in 11l, the logic is even easier to remember: 3r30000.  3r33818.
 3r33818.
 3r33818. 3r3804. Python 3r3807.  3r33818. 3r3804. 11l 3r3807.  3r33818. 3r3809.  3r33818.
 3r33818. 3r3804. 3r3667. 3r3658. items =['A', 'B', 'C']3r33818. for index, item in enumerate (items):
print (str (index) + '=' + item)
3r3673.
 3r33818. 3r3804. 3r3667. 3r3668. var items =[‘A’, ‘B’, ‘C’]3r33818. loop (item) items
print (loop.index ‘=’ item)
3r3673.
 3r33818. 3r3809.  3r33818. 3r33811. 3r33800.  3r33818.
Performance 3r38282. 3r33800.  3r33818. As a test used
a program for converting pc markup to HTML [/leech] , and the source data is taken source articles on pc markup
[так как эта статья на данный момент — самая большая из написанных на пк-разметке]3r3772. , and repeated 10 times, that is, a 488 KB file is obtained from a 48.8 kilobyte article. 3r33800.  3r33818. 3r33800.  3r33818. Here is a diagram showing how many times the corresponding method of executing Python code is faster than the original implementation of 3r3771.[CPython]3r3772. : 3r33800.  3r33818. 3r33737. 3r33714. 3r33800.  3r33818. Run time 3r3771.[время преобразования файла размером 488Кб]3r3772. was 868 ms for CPython and 38 ms for the generated C ++ code
[это время включает в себя полноценный [т.е. не просто работу Shed Skin but it does not support local functions. 3r33800.  3r33818. Numba also failed (yields an error ‘Use of unknown opcode LOAD_BUILD_CLASS’). 3r33800.  3r33818. 3r33737. Here is the archive 3r3806. with the program used to compare performance 3r3771.[под Windows]3r3772. (Requires installed Python 3.6 or higher and the following Python packages: pywin3? cython). 3r33800.  3r33818. 3r33838. 3r33838. 3r33800.  3r33818. Python source and output of Python transpilers → 11l and 11l → C ++:
 3r33818.
 3r33818.
 3r33818. 3r3804. Python
 3r33818. 3r3804. Generated 11l 3r33800.  3r33818. (with keywords instead of letters)
 3r33818. 3r3804. 11l 3r3806. 3r33800.  3r33818. (with letters)
 3r33818. 3r3804. 3r3805. Generated C ++

 3r33818. 3r3809.  3r33818. 3r33811. 3r33838. 3r33818. 3r33818. 3r33818. 3r33816. ! function (e) {function t (t, n) {if (! (n in e)) {for (var, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r33817. 3r33818. 3r33838.

It may be interesting

  • Comments
  • About article
  • Similar news
tamsynknight 26 July 2020 21:37
STEVEBURCHMUSIC – DOWNLOAD MP3 & AIFF LOSSELESS TOP MUSIC
Website https://steveburchmusic.com/

weber

Author

28-11-2018, 07:38

Publication Date

Python / Abnormal programming / C#

Category
  • Comments: 1
  • Views: 1 527
Godot: Regular use of static code
Build a system of reactive components
Testing the white box
Leaving go? Night talk about layoffs
We pick Shararam - 1 part
Build a web-based server farm for
Write a comment
Name:*
E-Mail:


Comments
I know your aptitude on this. I should say we ought to have an online discourse on this. Composing just remarks will close the talk straight away! What's more, will confine the advantages from this data. 審計 報告

Today, 15:43

nushra45

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing香港利得稅

Today, 15:02

nushra45

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. 먹튀
Today, 14:46

seo servise

If you are looking for more information about flat rate locksmith Las Vegas check that right away.  best front load washing machine in india
Today, 13:15

jacksonseo


Here we introduce our top coupons that will help you for online shopping at discountable prices.Revounts bring you the best deals that slash the bills.If you are intrested in online shopping and want to save your savings then visit our site for best experience.
Today, 08:41

Emma Taylor

Adv
Website for web developers. New scripts, best ideas, programming tips. How to write a script for you here, we have a lot of information about various programming languages. You are a webmaster or a beginner programmer, it does not matter, useful articles will help to make your favorite business faster.

Login

Registration Forgot password