Telegram Group & Telegram Channel
آشنایی با تابع ()compile - مقدمه ای بر JiT
اگر از کاربران قدیمی پایتون باشید، یکی از مسائلی که همیشه به آن اشاره می شد کندی برنامه های پایتون به دلیل استفاده از مفسر بود. اگر چه استفاده از مفسر برای کارهای علم داده که عموما با آزمون و خطا به حل مسئله می پردازیم خیلی هم بد نبود و حتی سرعت توسعه نرم افزار را بالا می برد اما برای توسعه برنامه های تجاری راهکار بهینه ای نبود. خوشبختانه در نسخه های اخیر پایتون، JiT یا همان اجرای در لحظه (Just in Time) وارد ادبیات پایتون شده است.
یکی از توابع معرفی شده در این خصوص تابع ()compile است. این تابع به نحو قابل قبولی باعث بهبود عملکرد برنامه می شود، چرا که بایت‌کد که توسط ()compile تولید می‌شود، سریعتر از سورس برنامه اصلی نوشته شده به زبان پایتون اجرا می‌شود زیرا قبلاً به یک فرم قابل اجرا توسط مفسر تبدیل شده است.

یک مثال
#code by @python4finance
source_code = """
a=5
for i in range(a):
print(i)
if i==3:
print("*")
"""
compiled_code = compile(source_code, filename="<string>", mode="exec")
exec(compiled_code)


#پایتون_پیشرفته
#JiT
#compile

پایتون برای مالی
🆔 www.tg-me.com/nl/Python4Finance/com.python4finance
🆔 ble.ir/nl/Python4Finance/com.python4finance



tg-me.com/python4finance/1081
Create:
Last Update:

آشنایی با تابع ()compile - مقدمه ای بر JiT
اگر از کاربران قدیمی پایتون باشید، یکی از مسائلی که همیشه به آن اشاره می شد کندی برنامه های پایتون به دلیل استفاده از مفسر بود. اگر چه استفاده از مفسر برای کارهای علم داده که عموما با آزمون و خطا به حل مسئله می پردازیم خیلی هم بد نبود و حتی سرعت توسعه نرم افزار را بالا می برد اما برای توسعه برنامه های تجاری راهکار بهینه ای نبود. خوشبختانه در نسخه های اخیر پایتون، JiT یا همان اجرای در لحظه (Just in Time) وارد ادبیات پایتون شده است.
یکی از توابع معرفی شده در این خصوص تابع ()compile است. این تابع به نحو قابل قبولی باعث بهبود عملکرد برنامه می شود، چرا که بایت‌کد که توسط ()compile تولید می‌شود، سریعتر از سورس برنامه اصلی نوشته شده به زبان پایتون اجرا می‌شود زیرا قبلاً به یک فرم قابل اجرا توسط مفسر تبدیل شده است.

یک مثال

#code by @python4finance
source_code = """
a=5
for i in range(a):
print(i)
if i==3:
print("*")
"""
compiled_code = compile(source_code, filename="<string>", mode="exec")
exec(compiled_code)


#پایتون_پیشرفته
#JiT
#compile

پایتون برای مالی
🆔 www.tg-me.com/nl/Python4Finance/com.python4finance
🆔 ble.ir/nl/Python4Finance/com.python4finance

BY Python4Finance


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python4finance/1081

View MORE
Open in Telegram


Python4Finance Telegram | DID YOU KNOW?

Date: |

How to Buy Bitcoin?

Most people buy Bitcoin via exchanges, such as Coinbase. Exchanges allow you to buy, sell and hold cryptocurrency, and setting up an account is similar to opening a brokerage account—you’ll need to verify your identity and provide some kind of funding source, such as a bank account or debit card. Major exchanges include Coinbase, Kraken, and Gemini. You can also buy Bitcoin at a broker like Robinhood. Regardless of where you buy your Bitcoin, you’ll need a digital wallet in which to store it. This might be what’s called a hot wallet or a cold wallet. A hot wallet (also called an online wallet) is stored by an exchange or a provider in the cloud. Providers of online wallets include Exodus, Electrum and Mycelium. A cold wallet (or mobile wallet) is an offline device used to store Bitcoin and is not connected to the Internet. Some mobile wallet options include Trezor and Ledger.

The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.

Python4Finance from nl


Telegram Python4Finance
FROM USA