حسین خسروی

وبلاگ دانشگاهی حسین خسروی، عضو هیات علمی دانشگاه صنعتی شاهرود

حسین خسروی

وبلاگ دانشگاهی حسین خسروی، عضو هیات علمی دانشگاه صنعتی شاهرود

حسین خسروی

باتوجه به محدودیتهای صفحه شخصی موجود در سایت دانشگاه، این بلاگ را راه اندازی کردم.
اطلاعیه های مربوط به دروسی که تدریس می کنم و تمرینها در این وبلاگ قرار خواهد گرفت.
برای آگاهی از مطالب مربوط به هر درس، در قاب زیر (طبقه بندی موضوعی) روی نام درس کلیک کنید.

پیوندهای روزانه
  • ۰
  • ۰

#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 afternoon with your family. That is the pythonic way :)


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


http://sapp.ir/khosravi


پی نوشت (26 اسفند 96): تجربه عملی خودم را در مورد مقایسه این دو زبان ببینید: C++ یا پایتون

نظرات (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی