Telegram Group & Telegram Channel
آشنایی با تابع ()compile - مقدمه ای بر JiT - بخش دوم
یکی دیگر از ویژگی های هیجان انگیز تابع ()compile ، امکان توزیع برنامه بدون در اختیار گذاشتن سورس کد برنامه در اختیار استفاده کننده نهایی است. در حالت عادی مجبور بودیم که کل سورس برنامه را در اختیار استفاده کننده نهایی قرار دهیم که این موضوع باعث ایجاد نگرانی در دسترسی به کدها را داشت. به کمک تابع ()compile و ماژول marshal به راحتی می توان برنامه های پایتون را کامپایل کرد که علاوه بر سرعت بالاتر اجرای برنامه، امنیت فایل ها هم تا حدودی حفظ شود.

یک مثال

#code by @python4finance

import marshal

source_code = """
a=5
for i in range(a):
print(i)
if i==3:
print("*")
"""
compiled_code = compile(source_code, '<string>', 'exec')

with open('compiled_code.pyc', 'wb') as file:
marshal.dump(compiled_code, file)


برای خواندن فایل کامپایل شده هم به صورت زیر عمل می کنیم:
import marshal

with open('compiled_code.pyc', 'rb') as file:
compiled_code = marshal.load(file)

exec(compiled_code)



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

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



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

آشنایی با تابع ()compile - مقدمه ای بر JiT - بخش دوم
یکی دیگر از ویژگی های هیجان انگیز تابع ()compile ، امکان توزیع برنامه بدون در اختیار گذاشتن سورس کد برنامه در اختیار استفاده کننده نهایی است. در حالت عادی مجبور بودیم که کل سورس برنامه را در اختیار استفاده کننده نهایی قرار دهیم که این موضوع باعث ایجاد نگرانی در دسترسی به کدها را داشت. به کمک تابع ()compile و ماژول marshal به راحتی می توان برنامه های پایتون را کامپایل کرد که علاوه بر سرعت بالاتر اجرای برنامه، امنیت فایل ها هم تا حدودی حفظ شود.

یک مثال

#code by @python4finance

import marshal

source_code = """
a=5
for i in range(a):
print(i)
if i==3:
print("*")
"""
compiled_code = compile(source_code, '<string>', 'exec')

with open('compiled_code.pyc', 'wb') as file:
marshal.dump(compiled_code, file)


برای خواندن فایل کامپایل شده هم به صورت زیر عمل می کنیم:
import marshal

with open('compiled_code.pyc', 'rb') as file:
compiled_code = marshal.load(file)

exec(compiled_code)



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

پایتون برای مالی
🆔 www.tg-me.com/ye/Python4Finance/com.python4finance
🆔 ble.ir/ye/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/1082

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 messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Python4Finance from ye


Telegram Python4Finance
FROM USA