PYTHONL Telegram 4919
This media is not supported in your browser
VIEW IN TELEGRAM
🧠 Π£ΡΠΊΠΎΡ€ΡŒ import Π² Python-ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°Ρ… с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ lazy loading β€” Π±Π΅Π· измСнСния Π»ΠΎΠ³ΠΈΠΊΠΈ

Если Ρƒ тСбя ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ с тяТёлыми модулями (`pandas`, torch, tensorflow`), Π½ΠΎ ΠΎΠ½ΠΈ Π½Π΅ всСгда Π½ΡƒΠΆΠ½Ρ‹ β€” Π½Π΅ Π·Π°Π³Ρ€ΡƒΠΆΠ°ΠΉ ΠΈΡ… зря. Python позволяСт **ΠΎΡ‚Π»ΠΎΠΆΠΈΡ‚ΡŒ ΠΈΠΌΠΏΠΎΡ€Ρ‚ Π΄ΠΎ ΠΏΠ΅Ρ€Π²ΠΎΠ³ΠΎ использования**, Ρ‡Π΅Ρ€Π΅Π· встроённый `importlib.

Π’ΠΎΡ‚ ΠΊΠ°ΠΊ это выглядит Π½Π° ΠΏΡ€Π°ΠΊΡ‚ΠΈΠΊΠ΅:



import importlib

# ΠžΠ±Ρ‘Ρ€Ρ‚ΠΊΠ° для Π»Π΅Π½ΠΈΠ²ΠΎΠ³ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚Π°
def lazy_import(name):
return importlib.util.LazyLoader(importlib.import_module(name))

# ИспользованиС
np = lazy_import('numpy')
# numpy Π΅Ρ‰Ρ‘ Π½Π΅ Π·Π°Π³Ρ€ΡƒΠΆΠ΅Π½

# Π’Π΅ΠΏΠ΅Ρ€ΡŒ загрузится:
print(np.array([1, 2, 3]))


@pythonl
❀34πŸ‘17πŸ”₯5



tgoop.com/pythonl/4919
Create:
Last Update:

🧠 Π£ΡΠΊΠΎΡ€ΡŒ import Π² Python-ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°Ρ… с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ lazy loading β€” Π±Π΅Π· измСнСния Π»ΠΎΠ³ΠΈΠΊΠΈ

Если Ρƒ тСбя ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ с тяТёлыми модулями (`pandas`, torch, tensorflow`), Π½ΠΎ ΠΎΠ½ΠΈ Π½Π΅ всСгда Π½ΡƒΠΆΠ½Ρ‹ β€” Π½Π΅ Π·Π°Π³Ρ€ΡƒΠΆΠ°ΠΉ ΠΈΡ… зря. Python позволяСт **ΠΎΡ‚Π»ΠΎΠΆΠΈΡ‚ΡŒ ΠΈΠΌΠΏΠΎΡ€Ρ‚ Π΄ΠΎ ΠΏΠ΅Ρ€Π²ΠΎΠ³ΠΎ использования**, Ρ‡Π΅Ρ€Π΅Π· встроённый `importlib.

Π’ΠΎΡ‚ ΠΊΠ°ΠΊ это выглядит Π½Π° ΠΏΡ€Π°ΠΊΡ‚ΠΈΠΊΠ΅:



import importlib

# ΠžΠ±Ρ‘Ρ€Ρ‚ΠΊΠ° для Π»Π΅Π½ΠΈΠ²ΠΎΠ³ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚Π°
def lazy_import(name):
return importlib.util.LazyLoader(importlib.import_module(name))

# ИспользованиС
np = lazy_import('numpy')
# numpy Π΅Ρ‰Ρ‘ Π½Π΅ Π·Π°Π³Ρ€ΡƒΠΆΠ΅Π½

# Π’Π΅ΠΏΠ΅Ρ€ΡŒ загрузится:
print(np.array([1, 2, 3]))


@pythonl

BY Python/ django


Share with your friend now:
tgoop.com/pythonl/4919

View MORE
Open in Telegram


Telegram News

Date: |

Avoid compound hashtags that consist of several words. If you have a hashtag like #marketingnewsinusa, split it into smaller hashtags: β€œ#marketing, #news, #usa. As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content β€œcontravenes the laws of Hong Kong.” The administrator of a telegram group, "Suck Channel," was sentenced to six years and six months in prison for seven counts of incitement yesterday. It’s yet another bloodbath on Satoshi Street. As of press time, Bitcoin (BTC) and the broader cryptocurrency market have corrected another 10 percent amid a massive sell-off. Ethereum (EHT) is down a staggering 15 percent moving close to $1,000, down more than 42 percent on the weekly chart. Telegram message that reads: "Bear Market Screaming Therapy Group. You are only allowed to send screaming voice notes. Everything else = BAN. Text pics, videos, stickers, gif = BAN. Anything other than screaming = BAN. You think you are smart = BAN.
from us


Telegram Python/ django
FROM American