پایتون یا سی پلاس پلاس - Python or CPP

خرید بک لینک

#CPP_or_Python ?

تجربه یک برنامه نویس خبره در سایت StackOverFlow در مورد پایتون و سی پلاس پلاس


https://stackoverflow.com/questions/801657/is-python-faster-and-lighter-than-c


1. My experiences with Python show the same definite trend that Python is on the order of between 10 and 100 times #slower than C++ when doing any serious #number_crunching. There are many reasons for this, the major ones being:

a) Python is #interpreted, while C++ is #compiled;

b) Python has no #primitives, everything including the builtin types (int, float, etc.) are #objects;

c) a Python list can hold objects of #different type, so each entry has to store additional data about its type. These all severely hinder both runtime and #memory consumption.


This is no reason to ignore Python though. A lot of software doesn't require much time or memory even with the 100 time slowness factor. #Development_cost is where #Python #wins with the simple and concise style. This improvement on development cost often outweighs the cost of additional cpu and memory resources. When it doesn't, however, then C++ wins.


پاسخ یک پایتون کار به این تجربه:

2. All the slowest (>100x) usages of Python on the shootout are scientific operations that require high GFlop/s count. You #should_NOT use python for those anyways. The correct way to use python is to #import a #module that does those calculations, and then go have a relaxing afteoon with your family. That is the pythonic way :)


خلاصه کلام اینکه، در پایتون فرایند توسعه برنامه، خیلی سریعتر است، اما سرعت اجرا برنامه بسیار کمتر از برنامه C++ است (10 برابر کندتر) . البته سرعت کمتر را با نوشتن ماژولهای محاسباتی در C++ و import کردن آنها در پایتون می شود جبران کرد!


http://sapp.ir/khosravi

برنامه نویسی - تمرین سری صفرم...

ما را در سایت برنامه نویسی - تمرین سری صفرم دنبال می‌کنید

برچسب: نویسنده: بازدید: 140 تاريخ: سه شنبه 9 آبان 1396 ساعت: 2:54

صفحه بندی