python受保护属性
重点(Top highlight)
Python was released in the 1990s as a general-purpose programming language.
Python于1990年代作为通用编程语言发布。
Despite its clean syntax, the exposure Python got in its first decade wasn’t encouraging, and it didn’t really find inroads into the developer’s workspace. Perl was the first choice scripting language and Java had established itself as the go-to in the object-oriented programming arena. Of course, any language takes time to mature and only gets adopted when it’s better suited to a task than the existing tools.
尽管语法简洁,但Python在其诞生的第一个十年中所获得的曝光率并不令人鼓舞,并且它并没有真正侵入开发人员的工作区。 Perl是首选脚本语言,而Java已成为面向对象编程领域的首选。 当然,任何语言都需要时间才能成熟,并且只有在比现有工具更适合任务时才被采用。
For Python, that time first arrived during the early 2000s when people started realizing it has an easier learning curve than Perl and offers interoperability with other languages.
对于Python来说,这个时间最早是在2000年代初,那时人们开始意识到它比Perl更容易学习,并且可以与其他语言互操作。
This realization led to a larger number of developers incorporating Python into their applications. The emergence of Django eventually led to the doom of Perl, and Python started gaining more momentum. Still, it wasn’t even close in popularity to Java and JavaScript, both of which were newer than Python.
这种认识导致大量开发人员将Python集成到他们的应用程序中。 Django的出现最终导致了Perl的灭顶之灾,Python开始获得更大的发展动力。 尽管如此,它甚至还没有普及到Java和JavaScript,而Java和JavaScript都比Python更新。
Fast forward to the present, and Python has trumped Java to become the second-most-popular language according to the StackOverflow Developer Survey 2019.
Swift发展到现在,根据2019年StackOverflow开发人员调查,Python已超越Java成为第二受欢迎的语言。
It was also the fastest-growing programming language of the previous decade. Python’s rise in popularity has a lot to do with the emergence of big data in the 2010s as well as developments in machine learning and artificial intelligence. Businesses urgently required a language for quick development with low barriers of entry that could help manage large-scale data and scientific computing tasks. Python was well-suited to all these challenges.
它也是过去十年中增长最快的编程语言。 Python的普及与很大程度上取决于2010年代大数据的出现以及机器学习和人工智能的发展。 企业迫切需要一种具有低进入门槛的快速开发语言,可以帮助管理大规模数据和科学计算任务。 Python非常适合所有这些挑战。
Besides having those factors in its favor, Python was an interpreted language with dynamic typing support. More importantly, it had the backing of Google, who’d invested in Python for Tensorflow, which led to its emergence as the preferred language for data analysis, visualization, and machine learning.
除了有利于这些因素之外,Python是一种具有动态类型支持的解释型语言。 更重要的是,它得到了Google的支持,后者为Tensorflow投资了Python,这导致它成为数据分析,可视化和机器学习的首选语言。
Yet, despite the growing demand for machine learning and AI at the turn of this decade, Python won’t stay around for long. Like every programming language, it has its own set of weaknesses. Those weaknesses make it vulnerable to replacement by languages more suited to the common tasks businesses ask of them. Despite the presence of R, the emergence of newer languages such as Swift, Julia, and Rust actually poses a bigger threat to the current king of data science.
然而,尽管在本世纪初,对机器学习和AI的需求不断增长,但是Python不会存在很长时间。 像每种编程语言一样,它也有自己的弱点。 这些弱点使其很容易被更适合企业要求他们执行的常见任务的语言替换。 尽管存在R,但是诸如Swift,Julia和Rust的较新语言的出现实际上对当前的数据科学之王构成了更大的威胁。
Rust is still trying to catch up with the machine learning community, and so I believe Swift and Julia are the languages that will dethrone Python and eventually rule data science. Let’s see why odds are against Python.
Rust仍在努力追赶机器学习社区,因此我相信Swift和Julia是将取代Python并最终统治数据科学的语言。 让我们看看为什么反对Python的可能性很大。
Python缺乏类型安全性,而且速度非常慢 (Python lacks type-safety and is super slow)
All good things come at a cost, and Python’s dynamically typed nature is no exception. It hampers developers, especially when running the code in production. Dynamic typing that makes it easy to write code quickly without defining types increases the risk of running into runtime issues, especially when the codebase size increases. Bugs that a compiler would easily figure out could go unidentified in Python, causing hindrances in production and ultimately slowing the development process in large-scale applications.
所有的好事都是有代价的,Python的动态类型化也不例外。 它会阻碍开发人员,特别是在生产环境中运行代码时。 动态类型可以轻松快速地编写代码而无需定义类型,这增加了遇到运行时问题的风险,尤其是当代码库大小增加时。 编译器容易发现的错误可能在Python中无法识别,从而导致生产障碍,并最终减慢了大型应用程序的开发过程。
Worse, unlike compiled code, Python’s interpreter analyzes every line of code at execution time. This leads to an overhead that causes a significantly slower performance when compared to other languages.
更糟糕的是,与编译后的代码不同,Python的解释器会在执行时分析每一行代码。 与其他语言相比,这会导致开销,从而导致性能显着降低。
Julia allows you to avoid some of these problems. Despite being dynamically typed, it has a just-in-time compiler. The JIT compiler either generates the machine code right before it’s executed or uses previously stored, cached compilations, which makes it as performant as statically typed languages. More importantly, it has a key feature known as multiple dispatch that is like function overloading of OOPs, albeit at runtime. The power of multiple dispatch lies in its ability to handle different argument types without the need to create separate function names or nested if statements. This helps in writing compact code, which is a big win in numeric computations since unlike Python, you can easily scale solutions to deal with all types of arguments.
Julia帮助您避免其中的一些问题。 尽管可以动态键入,但它具有即时编译器。 JIT编译器要么在执行之前就生成机器代码,要么使用以前存储的缓存编译,这使其像静态类型的语言一样具有高性能。 更重要的是,它具有一个称为多调度的关键功能,就像在运行时一样,类似于OOP的函数重载。 多重调度的强大之处在于它能够处理不同的参数类型,而无需创建单独的函数名称或嵌套的if语句。 这有助于编写紧凑的代码,这是数字计算的一大胜利,因为与Python不同,您可以轻松扩展解决方案以处理所有类型的参数。
Even better, Swift is a statically typed language and is highly optimized due to its LLVM (Low-Level Virtual Machine) compiler. The LLVM makes it possible to quickly compile into assembly code, making Swift super-efficient and almost as fast as C. Also, Swift boasts better memory safety and management tools known as Automatic Reference Counting. Unlike garbage collectors, ARC is a lot more deterministic as it reclaims memory whenever the reference count hits zero.
更好的是,Swift是一种静态类型的语言,并且由于其LLVM(低级虚拟机)编译器而得到了高度优化。 LLVM使快速编译成汇编代码成为可能,从而使Swift超级高效,几乎与C一样快。而且,Swift拥有更好的内存安全性和管理工具,称为自动引用计数。 与垃圾收集器不同,ARC具有更多的确定性,因为只要引用计数达到零,它就会回收内存。
As compiled languages that offer type annotations, Swift and Julia are a lot faster and robust for development than Python. That alone might be enough to recommend them over the older language, but there are other factors to consider as well.
作为提供类型注释的已编译语言,Swift和Julia在开发方面比Python快得多,而且功能强大。 仅凭这一点就可以推荐他们使用较旧的语言,但是还需要考虑其他因素。
Python在并行性方面有局限性(Python has limitations in parallelism)
If slowness was not the most obvious drawback of Python, the language also has limitations with parallel computing.
如果慢不是Python的最明显缺点,那么该语言在并行计算方面也有局限性。
In short, Python uses GIL (Global Interpreter Lock), which prevents multiple threads from executing at the same time in order to boost the performance of single threads. This process is a big hindrance because it means that developers cannot use multiple CPU cores for intensive computing.
简而言之,Python使用GIL(全局解释器锁),该功能可防止多个线程同时执行,以提高单个线程的性能。 这个过程是一个很大的障碍,因为这意味着开发人员无法使用多个CPU内核进行密集计算。
I agree with the commonplace notion that we’re currently doing fine when leveraging Python’s interoperability with C/C++ libraries like Tensorflow and PyTorch. But a Python wrapper doesn’t solve all debugging issues. Ultimately, when inspecting the underlying low-level code, we’re falling back on C and C++. Essentially, we can’t leverage the strengths of Python at the low level, which puts it out of the picture.
我同意一个普遍的观点,即在利用Python与Tensorflow和PyTorch之类的C / C ++库的互操作性时,我们目前做得很好。 但是Python包装器并不能解决所有调试问题。 最终,当检查底层的底层代码时,我们将依赖于C和C ++。 从本质上讲,我们不能在低层次上利用Python的优势,这使它与众不同。
This factor will soon play a decisive role in the fall of Python and rise of Julia and Swift. Julia is a language exclusively designed to address the shortcomings of Python. It primarily offers three features: coroutines (asynchronous tasks), multi-threading, and distributed computing — all of which only show the immense possibilities for concurrent and parallel programming. This structure makes Julia capable of performing scientific computations and solving big data problems at a far greater speed than Python.
这个因素将很快在Python的衰落以及Julia和Swift的崛起中起决定性作用。 Julia是专为解决Python缺点而设计的一种语言。 它主要提供三个功能:协程(异步任务),多线程和分布式计算-所有这些都仅显示出并行和并行编程的巨大可能性。 这种结构使Julia能够以比Python更快的速度执行科学计算并解决大数据问题。
On the other hand, Swift possesses all the tools required for developing mobile apps and has no problems with parallel computing.
另一方面,Swift拥有开发移动应用程序所需的所有工具,并且并行计算没有问题。
Swift和Julia具有Python的互操作性和强大的支持力 (Swift and Julia have Python’s interoperability and strong support in their favor)
Despite the disadvantages it has with respect to speed, multi-threading, and type-safety, Python still has a huge ecosystem that boasts an enormous set of libraries and packages. Understandably, Swift, and Julia are still infants in the field of machine learning and possess only a limited number of libraries. Yet, their interoperability with Python more than compensates for the lack of library support in Julia and Swift.
尽管Python在速度,多线程和类型安全方面存在缺点,但Python仍然拥有庞大的生态系统,其中包含大量的库和程序包。 可以理解,Swift和Julia仍然是机器学习领域的雏形,并且仅拥有有限的库。 但是,它们与Python的互操作性弥补了Julia和Swift中缺乏库支持的不足。
Julia not only lets programmers use Python code (and vice-versa), but also supports interoperability with C, R, Java, and almost every major programming language. This versatility would certainly give the language a good boost and increase its chances of a quick adoption among data scientists.
Julia不仅允许程序员使用Python代码(反之亦然),而且还支持与C,R,Java和几乎所有主要编程语言的互操作性。 这种多功能性无疑将使该语言得到很好的提升,并增加其在数据科学家中Swift被采用的机会。
Swift, on the other hand, provides interoperability with Python with the PythonKit library. The biggest selling point for Swift (which has an Apple origin) is a strong support it’s been getting from Google, who fully backed Python decades ago. See how the tables have turned!
另一方面,Swift通过PythonKit库提供了与Python的互操作性。 Swift(起源于苹果公司)最大的卖点是它得到了谷歌的大力支持,谷歌几十年前就全力支持Python。 看看桌子如何转动!
Also, the fact that the creator of Swift, Chris Lattner, is now working on Google’s AI brain team just shows that Swift is being seriously groomed as Python’s replacement in the machine learning field. The Tensorflow team investing in Swift with their S4TF project only further proves that the language isn’t merely regarded as a wrapper over Python. Instead Swift, thanks to its differential programming support and ability to work at a low level like C, will potentially be used to replace the underlying deep learning tools.
此外,Swift的创建者Chris Lattner现在正在Google的AI大脑团队工作的事实表明,Swift被认真地修饰为Python在机器学习领域的替代者。 Tensorflow团队通过其S4TF项目投资了Swift,这进一步证明了该语言不仅被视为Python的包装。 取而代之的是,Swift凭借其差异化的编程支持和像C一样的低级工作能力,将有可能被用来取代基础的深度学习工具。
结论 (Conclusion)
As the size of data continues to increase, Python’s Achilles heel will be soon found out. Gone are the days when ease of use and ability to write code quickly mattered. Speed and parallel computing are the names of the game and Python, which is a more general-purpose language, will no longer solve that problem. Inevitably, it will fade away while Julia and Swift seem like the candidates to take over the reins.
随着数据量的不断增加,很快就会发现Python的致命弱点。 易用性和快速编写代码的能力已不再重要的日子了。 速度和并行计算是游戏的名称,Python是一种通用语言,将不再解决该问题。 不可避免地,它会消失,而茱莉亚(Julia)和斯威夫特(Swift)似乎是接任总统的候选人。
It’s important to note that Python as a programming language won’t disappear any time soon. Instead, it’ll only take a backseat in data science as the languages that are more specifically designed for deep learning will rule.
重要的是要注意,Python作为一种编程语言不会很快消失。 取而代之的是,它将只在数据科学领域处于后座地位,因为专门为深度学习而设计的语言将成为主流。
python受保护属性