- 1 1. ã¯ããã«
- 2 2. ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®æ¯èŒ
- 3 3. ã¹ã¬ãããšããã»ã¹ã®åºæ¬æŠå¿µ
- 4 4. Pythonã§ã®ãã«ãã¹ã¬ããå®è£
- 5 5. ãã«ãã¹ã¬ããã®æŽ»çšäŸ
- 6 6. ãã«ãã¹ã¬ãã䜿çšæã®æ³šæç¹ãšãã¹ããã©ã¯ãã£ã¹
- 7 7. ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®æ¯èŒ
- 8 8. ãŸãšããšFAQ
- 8.1 æ¬èšäºã®èŠç¹
- 8.2 FAQïŒãããã質åïŒ
- 8.2.1 Q1: ãã«ãã¹ã¬ããã䜿çšããéãã¹ã¬ããæ°ã¯äœåãé©åã§ããïŒ
- 8.2.2 Q2: GILã®å¶çŽãå®å šã«åé¿ããæ¹æ³ã¯ãããŸããïŒ
- 8.2.3 Q3: ãã«ãã¹ã¬ãããšéåæåŠçïŒasyncioïŒã¯ã©ãéããŸããïŒ
- 8.2.4 Q4: Pythonã§ã¹ã¬ããããŒã«ã䜿ããšã©ã®ãããªã¡ãªããããããŸããïŒ
- 8.2.5 Q5: ãã«ãã¹ã¬ããã䜿çšãããšã¡ã¢ãªæ¶è²»éãå¢ããŸããïŒ
- 8.3 çµè«
1. ã¯ããã«
Pythonã¯ããã®ã·ã³ãã«ã§äœ¿ããããæ§æãè±å¯ãªã©ã€ãã©ãªã«ãã£ãŠãåå¿è ããäžçŽè ãŸã§å¹ åºããŠãŒã¶ãŒã«å©çšãããŠããããã°ã©ãã³ã°èšèªã§ãããã®äžã§ããã«ãã¹ã¬ããã¯ç¹å®ã®ç¶æ³ã§åŠçå¹çãåçã«åäžãããããã®éèŠãªæè¡ã§ãã
Pythonã§ãã«ãã¹ã¬ããã䜿çšããçç±
ã³ã³ãã¥ãŒã¿ã®æ§èœåäžã«äŒŽããããã°ã©ã ãäžåºŠã«åŠçããããŒã¿ã®éãã¹ããŒããžã®èŠæ±ãé«ãŸã£ãŠããŸããç¹ã«ä»¥äžã®ãããªã·ãŒã³ã§ã¯ããã«ãã¹ã¬ããã®æŽ»çšãå¹æçã§ãã
- 倧éããŒã¿ã®åŠç: ããŒã¿ããŒã¹ããã®ããŒã¿ååŸãã倧éã®ãã¡ã€ã«ãæ±ãå Žåã«ã䞊ååã«ããåŠçæéãççž®ã§ããŸãã
- I/Oæäœã®å¹çå: ãã¡ã€ã«ã®èªã¿æžãããããã¯ãŒã¯éä¿¡ãªã©ãI/Oæäœãå€ãããã°ã©ã ã§åŸ ã¡æéãæå°éã«ã§ããŸãã
- ãªã¢ã«ã¿ã€ã æ§ã®èŠæ±: ã²ãŒã ããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ã®ããã°ã©ãã³ã°ã§ã¯ãåæã«è€æ°ã®åŠçãè¡ãå¿ èŠãããããããã«ãã¹ã¬ãããå¿ é ãšãªããŸãã
ãã«ãã¹ã¬ããã®ã¡ãªãããšèª²é¡
ã¡ãªãã
- åŠçé床ã®åäž: è€æ°ã®ã¹ã¬ããã䞊è¡ããŠåäœããããšã§ãåŠçãå¹ççã«åæ£ã§ããŸãã
- ãªãœãŒã¹ã®æå¹æŽ»çš: äžéšã®ã¹ã¬ãããåŸ æ©äžã§ããä»ã®ã¹ã¬ãããCPUãªãœãŒã¹ã掻çšã§ããŸãã
課é¡
- ã°ããŒãã«ã€ã³ã¿ããªã¿ããã¯ïŒGILïŒã®å¶çŽ: Pythonã§ã¯ãGILã®ååšã«ãããã«ãã¹ã¬ããã®å¹æãå¶éãããå ŽåããããŸãã
- ãããã°ã®è€éã: ã¹ã¬ããéã®ç«¶åããããããã¯ãªã©ã®åé¡ãçºçããããããããã°ã«æéããããããšããããŸãã
æ¬èšäºã®ç®ç
æ¬èšäºã§ã¯ãPythonã§ãã«ãã¹ã¬ãããå®è£ ããéã®åºæ¬çãªèãæ¹ãå ·äœçãªæ¹æ³ã解説ããŠãããŸãããŸããå®éã®äœ¿çšäŸã泚æç¹ãæããããšã§ãå®åã§ã®æŽ»çšæ¹æ³ãåŠã¹ãå 容ãšãªã£ãŠããŸããç¹ã«ãåå¿è ããäžçŽè ãç解ããããããã«æ®µéçã«é²ããŠãããŸãã®ã§ããã²æåŸãŸã§ãèªã¿ãã ããã
2. ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®æ¯èŒ
ããã°ã©ãã³ã°ã«ãããŠããã«ãã¹ã¬ãããšãã«ãããã»ã¹ã¯ã©ã¡ãã䞊ååŠçãå®çŸããããã®éèŠãªæè¡ã§ãããããããç°ãªãç¹åŸŽãšé©çšå Žé¢ããããŸããæ¬ã»ã¯ã·ã§ã³ã§ã¯ãäž¡è ã®éããšPythonã§ã®äœ¿ãåãã«ã€ããŠè©³ãã解説ããŸãã
ã¹ã¬ãããšããã»ã¹ã®åºæ¬çãªéã
ã¹ã¬ãããšã¯
ã¹ã¬ããã¯ãåäžã®ããã»ã¹å ã§äžŠååŠçãå®çŸããåäœã§ããåãã¡ã¢ãªç©ºéãå ±æãããããããŒã¿ã®ããåããé«éã«è¡ããŸãã
- ç¹åŸŽ:
- ã¡ã¢ãªç©ºéãå ±æ
- 軜éã§èµ·åãéã
- ããŒã¿ã®å ±æã容æ
ããã»ã¹ãšã¯
ããã»ã¹ã¯ãç¬ç«ããã¡ã¢ãªç©ºéãæã€å®è¡åäœã§ããåããã»ã¹ãç¬èªã®ãªãœãŒã¹ãæã€ãããäºãã®åœ±é¿ãåãã«ããç¹åŸŽããããŸãã
- ç¹åŸŽ:
- ç¬ç«ããã¡ã¢ãªç©ºéãæã€
- ééã§èµ·åã«æéãããã
- ããŒã¿å ±æã«ã¯è¿œå ã®ä»çµã¿ãå¿ èŠ
Pythonã§ã®GILïŒã°ããŒãã«ã€ã³ã¿ããªã¿ããã¯ïŒã®åœ±é¿
Pythonã«ã¯ãGILïŒGlobal Interpreter LockïŒãšåŒã°ããå¶çŽããããŸãããã®ããã¯ã¯ãPythonã®ã¹ã¬ãããåæã«1ã€ããåäœã§ããªãããã«ããä»çµã¿ã§ããGILã®ååšã«ããããã«ãã¹ã¬ããã䜿ã£ãŠãCPUã®ãã«ãã³ã¢æ§èœãæ倧éã«æŽ»çšã§ããªãå ŽåããããŸãã
- GILã®åœ±é¿ãåããããã±ãŒã¹:
- CPUè² è·ã®é«ãèšç®åŠçïŒäŸ: æ°å€æŒç®ãç»ååŠçïŒ
- GILã®åœ±é¿ãåãã«ããã±ãŒã¹:
- I/Oæäœãäžå¿ã®åŠçïŒäŸ: ãããã¯ãŒã¯éä¿¡ããã¡ã€ã«æäœïŒ
ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®äœ¿ãåã
ãã«ãã¹ã¬ãããéžã¶å Žå
- é©çšå Žé¢:
- I/Oæäœãå€ãããã°ã©ã
- 軜éãªã¿ã¹ã¯ã䞊åå®è¡ããå¿ èŠãããå Žå
- äŸ: Webã¹ã¯ã¬ã€ãã³ã°ããã¡ã€ã«ã®åæããŠã³ããŒã
ãã«ãããã»ã¹ãéžã¶å Žå
- é©çšå Žé¢:
- CPUè² è·ã®é«ãèšç®åŠç
- GILã®å¶çŽãåé¿ãããå Žå
- äŸ: æ©æ¢°åŠç¿ã¢ãã«ã®ãã¬ãŒãã³ã°ãç»ååŠç
Pythonã§ã®ç°¡åãªæ¯èŒäŸ
以äžã¯ãPythonã§threading
ã¢ãžã¥ãŒã«ãšmultiprocessing
ã¢ãžã¥ãŒã«ã䜿çšããŠãç°¡åãªäžŠååŠçãå®çŸããã³ãŒãäŸã§ãã
ãã«ãã¹ã¬ããã®äŸ
import threading
import time
def task(name):
print(f"{name} ã¹ã¿ãŒã")
time.sleep(2)
print(f"{name} çµäº")
threads = []
for i in range(3):
thread = threading.Thread(target=task, args=(f"ã¹ã¬ãã {i+1}",))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("å
šã¹ã¬ããçµäº")
ãã«ãããã»ã¹ã®äŸ
from multiprocessing import Process
import time
def task(name):
print(f"{name} ã¹ã¿ãŒã")
time.sleep(2)
print(f"{name} çµäº")
processes = []
for i in range(3):
process = Process(target=task, args=(f"ããã»ã¹ {i+1}",))
processes.append(process)
process.start()
for process in processes:
process.join()
print("å
šããã»ã¹çµäº")
çµè«
ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã«ã¯ããããé©åãªçšéããããŸããPythonã§äžŠååŠçãå®çŸããéã¯ãããã°ã©ã ã®ç¹æ§ãGILã®åœ±é¿ãèæ ®ããŠãæé©ãªææ³ãéžã¶ããšã倧åã§ãã

3. ã¹ã¬ãããšããã»ã¹ã®åºæ¬æŠå¿µ
ãã«ãã¹ã¬ããããã«ãããã»ã¹ãæ£ããç解ã掻çšããããã«ã¯ãããããã®åºæ¬çãªä»çµã¿ãç¹æ§ãç¥ãããšãéèŠã§ããæ¬ã»ã¯ã·ã§ã³ã§ã¯ãã¹ã¬ãããšããã»ã¹ãã©ã®ããã«åäœããã©ã®ãããªå Žåã«ããããé©ããŠããã®ãã解説ããŸãã
ã¹ã¬ããã®åºæ¬æŠå¿µ
ã¹ã¬ããã®åœ¹å²
ã¹ã¬ããã¯ãããã»ã¹å ã§å®è¡ãããç¬ç«ããåŠçã®æµããæããŸããåãããã»ã¹å ã®è€æ°ã®ã¹ã¬ããã¯ãã¡ã¢ãªç©ºéãå ±æããŠåäœãããããããŒã¿ã®å ±æãããåããã¹ã ãŒãºã«è¡ããŸãã
- ç¹åŸŽ:
- ããã»ã¹å ã§åäœãã軜éãªåäœã
- ã¡ã¢ãªç©ºéãå ±æãããããããŒã¿äº€æãé«éã
- ã¹ã¬ããéã§ã®åæã競åå¶åŸ¡ãå¿ èŠã
ã¹ã¬ããã®å©ç¹ãšèª²é¡
- å©ç¹:
- ã¡ã¢ãªå¹çãé«ãã
- 軜éã§èµ·åãåãæ¿ããéãã
- 課é¡:
- å ±æããŒã¿ã®ç«¶åããããããã¯ã®ãªã¹ã¯ãããã
- Pythonã§ã¯GILã®åœ±é¿ãåãããããCPUè² è·ã®é«ãåŠçã«ã¯åããªãã
ããã»ã¹ã®åºæ¬æŠå¿µ
ããã»ã¹ã®åœ¹å²
ããã»ã¹ã¯ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã«ãã£ãŠå²ãåœãŠãããç¬ç«ããå®è¡ç°å¢ã§ããåããã»ã¹ã¯ç¬èªã®ã¡ã¢ãªç©ºéãæã¡ãäºãã«åœ±é¿ãäžããŸããã
- ç¹åŸŽ:
- å®å šã«ç¬ç«ããã¡ã¢ãªç©ºéã䜿çšã
- ã»ãã¥ãªãã£ãå®å®æ§ãé«ãã
- ããã»ã¹ééä¿¡ïŒIPCïŒãå¿ èŠãªå Žåãå°ãè€éã«ãªãã
ããã»ã¹ã®å©ç¹ãšèª²é¡
- å©ç¹:
- GILã®åœ±é¿ãåããªããããCPUè² è·ã®é«ãåŠçã«æé©ã
- ããã»ã¹ãç¬ç«ããŠãããããå®å®æ§ãé«ãã
- 課é¡:
- ããã»ã¹ã®èµ·åãåãæ¿ãã«ã³ã¹ãããããã
- ã¡ã¢ãªäœ¿çšéãå¢å ããã
ã¹ã¬ãããšããã»ã¹ã®åäœæ¯èŒ
ç¹åŸŽ | ã¹ã¬ãã | ããã»ã¹ |
---|---|---|
ã¡ã¢ãªç©ºé | åãã¡ã¢ãªç©ºéãå ±æ | ç¬ç«ããã¡ã¢ãªç©ºé |
軜éæ§ | 軜é | éé |
èµ·åé床 | é«é | ããé ã |
ããŒã¿å ±æ | 容æ | IPCïŒããã»ã¹ééä¿¡ïŒãå¿ èŠ |
GILã®åœ±é¿ | åãã | åããªã |
é©çšå Žé¢ | I/Oæäœãäžå¿ã®åŠç | CPUè² è·ãé«ãèšç®åŠç |
ã°ããŒãã«ã€ã³ã¿ããªã¿ããã¯ïŒGILïŒã®ä»çµã¿
Pythonã§ã¯ãGILãã¹ã¬ããã®åäœãå¶åŸ¡ããŠããŸããGILã¯åæã«1ã€ã®ã¹ã¬ããã ããPythonãã€ãã³ãŒããå®è¡ã§ããããã«ããä»çµã¿ã§ããããã«ãããã¹ã¬ããéã®ããŒã¿ç«¶åãé²ãå¹æããããŸããããã«ãã³ã¢CPUãå¹ççã«æŽ»çšããããšãå¶éãããå ŽåããããŸãã
- GILã®ã¡ãªãã:
- ã¹ã¬ããéã®ããŒã¿ç«¶åãé²ããã¹ã¬ããå®å šæ§ã確ä¿ã
- GILã®ãã¡ãªãã:
- CPUè² è·ã®é«ãã¿ã¹ã¯ã§ã¯ããã«ãã¹ã¬ããã®æ§èœãå¶éãããã
ã¹ã¬ãããšããã»ã¹ã®éžæåºæº
Pythonã§äžŠååŠçãè¡ãå Žåã以äžã®åºæºã§ã¹ã¬ãããšããã»ã¹ãéžæãããšè¯ãã§ãããã
- ã¹ã¬ãããéžã¶å Žå:
- åŠçã®å€ããI/OåŸ ã¡ã§ããïŒäŸ: ãããã¯ãŒã¯éä¿¡ïŒã
- ã¡ã¢ãªäœ¿çšéãæãããã
- ããã»ã¹ãéžã¶å Žå:
- CPUãå€çšããåŠçïŒäŸ: æ°å€èšç®ïŒã
- è€æ°ã®ã³ã¢ãå¹ççã«æŽ»çšãããã
4. Pythonã§ã®ãã«ãã¹ã¬ããå®è£
Pythonã§ãã«ãã¹ã¬ãããå®è£
ããéã«ã¯ãæšæºã©ã€ãã©ãªã®threading
ã¢ãžã¥ãŒã«ã䜿çšããŸãããã®ã»ã¯ã·ã§ã³ã§ã¯ãåºæ¬çãªã¹ã¬ããã®äœæããé«åºŠãªå¶åŸ¡ãŸã§ãå
·äœçãªã³ãŒãäŸãšãšãã«è§£èª¬ããŸãã
threadingã¢ãžã¥ãŒã«ã®åºæ¬çãªäœ¿ãæ¹
ã¹ã¬ããã®äœæãšå®è¡
threading
ã¢ãžã¥ãŒã«ã§ã¯ãThread
ã¯ã©ã¹ã䜿çšããŠã¹ã¬ãããäœæãå®è¡ããŸãã以äžã¯åºæ¬çãªäŸã§ãã
import threading
import time
def print_message(message):
print(f"éå§: {message}")
time.sleep(2)
print(f"çµäº: {message}")
## ã¹ã¬ããã®äœæ
thread1 = threading.Thread(target=print_message, args=("ã¹ã¬ãã1",))
thread2 = threading.Thread(target=print_message, args=("ã¹ã¬ãã2",))
## ã¹ã¬ããã®éå§
thread1.start()
thread2.start()
## ã¹ã¬ããã®çµäºãåŸ
æ©
thread1.join()
thread2.join()
print("å
šã¹ã¬ããçµäº")
å®è¡çµæã®èª¬æ
ãã®ã³ãŒãã§ã¯ã2ã€ã®ã¹ã¬ãããåæã«éå§ãããåã¹ã¬ãããç¬ç«ããŠåäœããŸããjoin()
ã¡ãœããã䜿çšããããšã§ããã¹ãŠã®ã¹ã¬ãããçµäºãããŸã§ã¡ã€ã³ã¹ã¬ããã®åŠçãåŸ
æ©ã§ããŸãã
ã¯ã©ã¹ã䜿ã£ãã¹ã¬ããã®å®è£
Thread
ã¯ã©ã¹ãç¶æ¿ããŠãããè€éãªã¹ã¬ããåŠçãå®è£
ããããšãå¯èœã§ãã
import threading
import time
class MyThread(threading.Thread):
def __init__(self, name):
super().__init__()
self.name = name
def run(self):
print(f"{self.name} éå§")
time.sleep(2)
print(f"{self.name} çµäº")
## ã¹ã¬ããã®äœæ
thread1 = MyThread("ã¹ã¬ãã1")
thread2 = MyThread("ã¹ã¬ãã2")
## ã¹ã¬ããã®éå§
thread1.start()
thread2.start()
## ã¹ã¬ããã®çµäºãåŸ
æ©
thread1.join()
thread2.join()
print("å
šã¹ã¬ããçµäº")
å®è¡çµæã®èª¬æ
run()
ã¡ãœããã«åŠçå
容ãå®çŸ©ããstart()
ã¡ãœããã§ã¹ã¬ãããèµ·åããŸãããã®æ¹æ³ã¯ãè€éãªã¹ã¬ããåŠçãã¯ã©ã¹ãšããŠåå©çšãããå Žåã«äŸ¿å©ã§ãã
ã¹ã¬ããéã®åæãšããã¯
è€æ°ã®ã¹ã¬ãããåæã«å
±æããŒã¿ãæäœããå ŽåãããŒã¿ã®ç«¶åãäžæŽåãçºçããå¯èœæ§ããããŸãããã®ãããªåé¡ãé²ãããã«ãLock
ãªããžã§ã¯ãã䜿çšããŠã¹ã¬ããéã®åæãè¡ããŸãã
ããã¯ã䜿çšããäŸ
import threading
lock = threading.Lock()
shared_resource = 0
def increment():
global shared_resource
with lock: ## ããã¯ãååŸ
local_copy = shared_resource
local_copy += 1
shared_resource = local_copy
threads = []
for i in range(5):
thread = threading.Thread(target=increment)
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print(f"å
±æãªãœãŒã¹ã®æçµå€: {shared_resource}")
å®è¡çµæã®èª¬æ
with lock
æ§æã䜿çšããããšã§ãããã¯ãå®å
šã«ååŸã»è§£æŸã§ããŸãããã®äŸã§ã¯ãããã¯ã䜿çšããŠå
±æãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ã1ã¹ã¬ããã«éå®ããŠããŸãã
ã¹ã¬ããã®ã¿ã€ã ã¢ãŠããšããŒã¢ã³ã¹ã¬ãã
ã¹ã¬ããã®ã¿ã€ã ã¢ãŠã
join()
ã¡ãœããã«ã¿ã€ã ã¢ãŠããèšå®ãããšãã¹ã¬ããã®çµäºãæå®ããæéã ãåŸ
æ©ã§ããŸãã
thread.join(timeout=5)
ããŒã¢ã³ã¹ã¬ãã
ããŒã¢ã³ã¹ã¬ããã¯ãã¡ã€ã³ã¹ã¬ãããçµäºãããšèªåçã«åæ¢ããŸããã¹ã¬ãããããŒã¢ã³ãšããŠèšå®ããã«ã¯ãdaemon
å±æ§ãTrue
ã«èšå®ããŸãã
thread = threading.Thread(target=print_message)
thread.daemon = True
thread.start()
å®åã§ã®ãã«ãã¹ã¬ãã掻çšäŸ
以äžã¯ããã¡ã€ã«ããŠã³ããŒãã䞊ååããäŸã§ãã
import threading
import time
def download_file(file_name):
print(f"{file_name} ã®ããŠã³ããŒãéå§")
time.sleep(2) ## ããŠã³ããŒããã·ãã¥ã¬ãŒã
print(f"{file_name} ã®ããŠã³ããŒãå®äº")
files = ["file1", "file2", "file3"]
threads = []
for file in files:
thread = threading.Thread(target=download_file, args=(file,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("å
šãã¡ã€ã«ã®ããŠã³ããŒãå®äº")
çµè«
ãã®ã»ã¯ã·ã§ã³ã§ã¯ãPythonã§ã®ãã«ãã¹ã¬ããã®åºæ¬çãªå®è£ æ¹æ³ãããå®åã§ã®å¿çšäŸãŸã§ã解説ããŸããã次ã®ã»ã¯ã·ã§ã³ã§ã¯ããã«ãã¹ã¬ããã®å ·äœçãªæŽ»çšäŸãããã«æ·±æãããŠè§£èª¬ããŸãã

5. ãã«ãã¹ã¬ããã®æŽ»çšäŸ
Pythonã®ãã«ãã¹ã¬ããã¯ãç¹ã«I/OåŸ ã¡ãå€ãåŠçã«é©ããŠããŸãããã®ã»ã¯ã·ã§ã³ã§ã¯ããã«ãã¹ã¬ãããå©çšããå ·äœçãªå¿çšäŸãããã€ã玹ä»ããŸãããããã®äŸãéããŠãçŸå®ã®ãããžã§ã¯ãã§ã©ã®ããã«æŽ»çšã§ããã®ããåŠã³ãŸãããã
1. Webã¹ã¯ã¬ã€ãã³ã°ã®å¹çå
Webãµã€ãããããŒã¿ãåéããéãè€æ°ã®URLã«å¯ŸããŠäžŠè¡ããŠãªã¯ãšã¹ããéãããšã§ãåŠçæéãå€§å¹ ã«ççž®ã§ããŸãã
ãµã³ãã«ã³ãŒã
以äžã¯ãPythonã®requests
ã©ã€ãã©ãªãšthreading
ã¢ãžã¥ãŒã«ã䜿çšããWebã¹ã¯ã¬ã€ãã³ã°ã®äŸã§ãã
import threading
import requests
import time
urls = [
"https://example.com/page1",
"https://example.com/page2",
"https://example.com/page3"
]
def fetch_url(url):
print(f"{url} ã®ååŸéå§")
response = requests.get(url)
print(f"{url} ã®ååŸå®äº: ã¹ããŒã¿ã¹ã³ãŒã {response.status_code}")
threads = []
start_time = time.time()
for url in urls:
thread = threading.Thread(target=fetch_url, args=(url,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
end_time = time.time()
print(f"åŠçæé: {end_time - start_time:.2f}ç§")
å®è¡çµæã®èª¬æ
ãã®ã³ãŒãã§ã¯ãåURLãžã®ãªã¯ãšã¹ãã䞊åã§å®è¡ããããããåèšåŠçæéãççž®ãããŸãããã ãããªã¯ãšã¹ãæ°ãå€ãå Žåã¯ããµãŒããŒè² è·ãèŠçŽéåã«æ³šæããŠãã ããã
2. ãã¡ã€ã«ã®åæããŠã³ããŒã
è€æ°ã®ãã¡ã€ã«ãã€ã³ã¿ãŒãããããããŠã³ããŒãããéããã«ãã¹ã¬ããã䜿ãã°å¹ççã«åŠçã§ããŸãã
ãµã³ãã«ã³ãŒã
import threading
import time
def download_file(file_name):
print(f"{file_name} ã®ããŠã³ããŒãéå§")
time.sleep(2) ## ããŠã³ããŒããã·ãã¥ã¬ãŒã
print(f"{file_name} ã®ããŠã³ããŒãå®äº")
files = ["file1.zip", "file2.zip", "file3.zip"]
threads = []
for file in files:
thread = threading.Thread(target=download_file, args=(file,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("å
šãã¡ã€ã«ã®ããŠã³ããŒãå®äº")
å®è¡çµæã®èª¬æ
ãã®ã³ãŒãã§ã¯ãåãã¡ã€ã«ã®ããŠã³ããŒãåŠçãã¹ã¬ããããšã«å®è¡ãããåŠçæéãççž®ãããŸããå®éã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãurllib
ãrequests
ã©ã€ãã©ãªã䜿çšããŠãªã¢ã«ãªããŠã³ããŒãåŠçãå®è£
ããŸãã
3. ããŒã¿ããŒã¹ã¯ãšãªã®äžŠåå®è¡
倧éã®ããŒã¿ãããŒã¿ããŒã¹ããååŸããå Žåããã«ãã¹ã¬ããã掻çšããŠã¯ãšãªã䞊åå®è¡ããããšã§ãåŠçé床ãåäžãããããšãã§ããŸãã
ãµã³ãã«ã³ãŒã
import threading
import time
def query_database(query):
print(f"ã¯ãšãªå®è¡äž: {query}")
time.sleep(2) ## ã¯ãšãªå®è¡ãã·ãã¥ã¬ãŒã
print(f"ã¯ãšãªå®äº: {query}")
queries = ["SELECT * FROM users", "SELECT * FROM orders", "SELECT * FROM products"]
threads = []
for query in queries:
thread = threading.Thread(target=query_database, args=(query,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("ãã¹ãŠã®ã¯ãšãªãå®äºããŸãã")
å®è¡çµæã®èª¬æ
ãã®äŸã§ã¯ãç°ãªãã¯ãšãªã䞊åã«å®è¡ããããšã§ãããŒã¿ååŸæéãççž®ããŠããŸããå®éã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãããŒã¿ããŒã¹ã©ã€ãã©ãªïŒäŸ: sqlite3
, psycopg2
ïŒã䜿çšããŠæ¥ç¶ããŸãã
4. åç»åŠçã®äžŠåå
åç»ãã¡ã€ã«ããã¬ãŒã ããšã«åŠçããã¿ã¹ã¯ã¯ããã«ãã¹ã¬ããã§å¹çåã§ããŸãã
ãµã³ãã«ã³ãŒã
import threading
import time
def process_frame(frame_number):
print(f"ãã¬ãŒã {frame_number} ã®åŠçéå§")
time.sleep(1) ## åŠçãã·ãã¥ã¬ãŒã
print(f"ãã¬ãŒã {frame_number} ã®åŠçå®äº")
frame_numbers = range(1, 6)
threads = []
for frame in frame_numbers:
thread = threading.Thread(target=process_frame, args=(frame,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("ãã¹ãŠã®ãã¬ãŒã åŠçãå®äºããŸãã")
å®è¡çµæã®èª¬æ
åç»ç·šéããšãã§ã¯ãåŠçãªã©ããã¬ãŒã åäœã®åŠçã䞊ååããããšã§ãå šäœã®åŠçé床ãåäžãããããšãã§ããŸãã
çµè«
ãã«ãã¹ã¬ããã¯ãI/Oæäœãå€çšããã·ã¹ãã ããªã¢ã«ã¿ã€ã æ§ãæ±ããããã¢ããªã±ãŒã·ã§ã³ã§å€§ããªå¹æãçºæ®ããŸãããã ããCPUè² è·ã®é«ãã¿ã¹ã¯ã§ã¯GILã®åœ±é¿ãèæ ®ãããã«ãããã»ã¹ãšã®é©åãªäœ¿ãåããæ€èšããå¿ èŠããããŸãã

6. ãã«ãã¹ã¬ãã䜿çšæã®æ³šæç¹ãšãã¹ããã©ã¯ãã£ã¹
Pythonã§ãã«ãã¹ã¬ãããå©çšããéã«ã¯ãå¹ççãªåŠçãå®çŸããäžæ¹ã§ã泚æãã¹ãç¹ãé¥ããã¡ãªåé¡ããããŸãããã®ã»ã¯ã·ã§ã³ã§ã¯ããã«ãã¹ã¬ããã®èª²é¡ãšãããåé¿ããããã®ãã¹ããã©ã¯ãã£ã¹ã玹ä»ããŸãã
泚æç¹
1. ã°ããŒãã«ã€ã³ã¿ããªã¿ããã¯ïŒGILïŒã®åœ±é¿
Pythonã®GILïŒGlobal Interpreter LockïŒã¯ãåæã«1ã€ã®ã¹ã¬ããããPythonãã€ãã³ãŒããå®è¡ã§ããªãå¶çŽã課ããŠããŸããããã«ãããCPUè² è·ã®é«ãåŠçïŒäŸ: æ°å€æŒç®ïŒã§ã¯ããã«ãã¹ã¬ããã®æ©æµãåãã«ãããªããŸãã
- 圱é¿ãåããã±ãŒã¹:
- 倧éã®èšç®åŠç
- é«ãCPU䜿çšçãå¿ èŠãªã¢ã«ãŽãªãºã
- åé¿ç:
multiprocessing
ã¢ãžã¥ãŒã«ã䜿çšããŠãã«ãããã»ã¹ã§äžŠååããã- GILãåé¿ããããã«Cæ¡åŒµã¢ãžã¥ãŒã«ãNumPyã®ãããªæé©åãããã©ã€ãã©ãªã掻çšããã
2. ãããããã¯
è€æ°ã®ã¹ã¬ãããäºãã«ãªãœãŒã¹ãåŸ ã¡ç¶ããç¶æ ïŒãããããã¯ïŒã¯ããã«ãã¹ã¬ããã§é »ç¹ã«çºçããåé¡ã§ããããã«ããããã°ã©ã å šäœãåæ¢ããŠããŸããŸãã
- äŸ:
ã¹ã¬ããAããªãœãŒã¹Xãä¿æããªãããªãœãŒã¹YãåŸ æ©ããã¹ã¬ããBããªãœãŒã¹Yãä¿æããªãããªãœãŒã¹XãåŸ æ©ããç¶æ³ã - åé¿ç:
- åžžã«ãªãœãŒã¹ãååŸããé åºãçµ±äžããã
threading
ã¢ãžã¥ãŒã«ã®RLock
ïŒååž°çããã¯ïŒã䜿çšããŠãããããã¯ãé²ãã
ãµã³ãã«ã³ãŒãïŒãããããã¯ã®åé¿ïŒ
import threading
lock1 = threading.Lock()
lock2 = threading.Lock()
def task1():
with lock1:
print("Task1ãlock1ãååŸ")
with lock2:
print("Task1ãlock2ãååŸ")
def task2():
with lock2:
print("Task2ãlock2ãååŸ")
with lock1:
print("Task2ãlock1ãååŸ")
thread1 = threading.Thread(target=task1)
thread2 = threading.Thread(target=task2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print("äž¡ã¿ã¹ã¯å®äº")
3. ã¬ãŒã¹ã³ã³ãã£ã·ã§ã³
è€æ°ã®ã¹ã¬ãããåãããŒã¿ãåæã«æäœããå Žåãäºæããªãåäœãçºçããå¯èœæ§ããããŸããããããã¬ãŒã¹ã³ã³ãã£ã·ã§ã³ããšåŒã³ãŸãã
- äŸ:
2ã€ã®ã¹ã¬ãããã«ãŠã³ã¿ãŒå€æ°ãåæã«ã€ã³ã¯ãªã¡ã³ãããããšãããšãæåŸ éãã«å¢å ããªãå ŽåããããŸãã - åé¿ç:
threading
ã¢ãžã¥ãŒã«ã®Lock
ã䜿çšããŠãå ±æããŒã¿ã®ã¢ã¯ã»ã¹ãåæããã- ã¹ã¬ããéã§ã®ããŒã¿ã®å ±æãæå°éã«æããã
ãµã³ãã«ã³ãŒãïŒããã¯ã䜿ã£ãåé¿ïŒ
import threading
lock = threading.Lock()
counter = 0
def increment():
global counter
with lock:
local_copy = counter
local_copy += 1
counter = local_copy
threads = [threading.Thread(target=increment) for _ in range(100)]
for thread in threads:
thread.start()
for thread in threads:
thread.join()
print(f"ã«ãŠã³ã¿ãŒã®å€: {counter}")
ãã¹ããã©ã¯ãã£ã¹
1. ã¹ã¬ããæ°ã®é©åãªèšå®
- ã¹ã¬ããæ°ã決ããéã¯ãCPUã³ã¢æ°ãI/OåŸ æ©æéãèæ ®ããŠãã ããã
- æšå¥š: I/OåŸ ã¡ã¿ã¹ã¯ã§ã¯ã¹ã¬ããæ°ãå¢ãããŠãåé¡ãããŸããããCPUéäžçãªã¿ã¹ã¯ã§ã¯ã³ã¢æ°ã«å¶éããã®ãäžè¬çã§ãã
2. ãããã°ãšãã®ã³ã°
- ãã«ãã¹ã¬ããããã°ã©ã ã¯ãããã°ãå°é£ã«ãªããããé©åãªãã®ã³ã°ãéèŠã§ãã
- æšå¥š: Pythonã®
logging
ã¢ãžã¥ãŒã«ã䜿çšããŠãã¹ã¬ããããšã«ãã°ãèšé²ããã
ãµã³ãã«ã³ãŒãïŒãã®ã³ã°ïŒ
import threading
import logging
logging.basicConfig(level=logging.DEBUG, format='%(threadName)s: %(message)s')
def task():
logging.debug("ã¿ã¹ã¯å®è¡äž")
threads = [threading.Thread(target=task) for _ in range(5)]
for thread in threads:
thread.start()
for thread in threads:
thread.join()
logging.debug("ãã¹ãŠã®ã¿ã¹ã¯ãå®äº")
3. é«ã¬ãã«ã©ã€ãã©ãªã®å©çš
concurrent.futures.ThreadPoolExecutor
ãªã©ã®é«ã¬ãã«ã©ã€ãã©ãªã䜿çšãããšãã¹ã¬ããã®ç®¡çãç°¡åã«ãªããŸãã
ãµã³ãã«ã³ãŒãïŒThreadPoolExecutorïŒ
from concurrent.futures import ThreadPoolExecutor
def task(name):
print(f"{name} å®è¡äž")
with ThreadPoolExecutor(max_workers=3) as executor:
executor.map(task, ["ã¿ã¹ã¯1", "ã¿ã¹ã¯2", "ã¿ã¹ã¯3"])
çµè«
Pythonã®ãã«ãã¹ã¬ãããå¹ççã«æŽ»çšããããã«ã¯ãGILãåæã®åé¡ã«æ³šæãæããªãããå®å šã§å¹ççãªèšèšãå¿ãããããšãéèŠã§ããé©åãªããã¯ã®äœ¿çšããããã°ææ³ãå¿ èŠã«å¿ããé«ã¬ãã«ã©ã€ãã©ãªã®æŽ»çšããæåãããã«ãã¹ã¬ããããã°ã©ã ãæ§ç¯ããéµãšãªããŸãã

7. ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®æ¯èŒ
Pythonã§äžŠååŠçãå®çŸããæ¹æ³ãšããŠãããã«ãã¹ã¬ããããšããã«ãããã»ã¹ãã®2ã€ããããŸããããããã«ç¹åŸŽããããé©çšããå Žé¢ãç°ãªããŸãããã®ã»ã¯ã·ã§ã³ã§ã¯ãäž¡è ã®éãã詳现ã«æ¯èŒããé©åãªäœ¿ãåãã®æéãæäŸããŸãã
ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®åºæ¬çãªéã
ç¹åŸŽ | ãã«ãã¹ã¬ãã | ãã«ãããã»ã¹ |
---|---|---|
å®è¡åäœ | åãããã»ã¹å ã®è€æ°ã®ã¹ã¬ãã | ç¬ç«ããè€æ°ã®ããã»ã¹ |
ã¡ã¢ãªç©ºé | å ±æïŒåãã¡ã¢ãªç©ºéã䜿çšïŒ | ç¬ç«ïŒããã»ã¹ããšã«åé¢ãããã¡ã¢ãªç©ºéïŒ |
軜éæ§ | 軜éã§èµ·åãéã | ééã§èµ·åã«æéãããã |
GILã®åœ±é¿ | åãã | åããªã |
ããŒã¿å ±æ | 容æïŒåãã¡ã¢ãªã䜿çšïŒ | è€éïŒããã»ã¹ééä¿¡ãå¿ èŠïŒ |
é©çšå Žé¢ | I/Oäžå¿ã®åŠç | CPUäžå¿ã®åŠç |
詳现解説
- ãã«ãã¹ã¬ãã:
è€æ°ã®ã¹ã¬ãããåãããã»ã¹å ã§åäœããããã軜éã§ããŒã¿ã®å ±æãç°¡åã§ããããããPythonã§ã¯GILã®å¶çŽã«ãããCPUè² è·ã®é«ãåŠçã§ã¯æ§èœãé æã¡ã«ãªãããšããããŸãã - ãã«ãããã»ã¹:
ããã»ã¹éã§ã¡ã¢ãªç©ºéãå ±æããªããããGILã®åœ±é¿ãåãããè€æ°ã®CPUã³ã¢ããã«æŽ»çšã§ããŸãããã ããããã»ã¹ééä¿¡ïŒIPCïŒãå¿ èŠãªå Žåãå®è£ ãããè€éã«ãªããŸãã
ãã«ãã¹ã¬ãããéžã¶ã¹ãå Žå
- é©çšäŸ:
- Webã¹ã¯ã¬ã€ãã³ã°
- ãã¡ã€ã«æäœïŒèªã¿æžãïŒ
- ãããã¯ãŒã¯éä¿¡ïŒéåæåŠçïŒ
- çç±:
ãã«ãã¹ã¬ããã¯I/OåŸ æ©æéãå¹ççã«æŽ»çšã§ãããããåŠçã®äžŠåæ§ãé«ããããŸãããŸããåãã¡ã¢ãªç©ºéãå ±æãããããããŒã¿ã®ããåããç°¡åã§ãã
ã³ãŒãäŸ: I/Oäžå¿ã®åŠç
import threading
import time
def file_operation(file_name):
print(f"{file_name} åŠçéå§")
time.sleep(2) ## ãã¡ã€ã«æäœãã·ãã¥ã¬ãŒã
print(f"{file_name} åŠçå®äº")
files = ["file1.txt", "file2.txt", "file3.txt"]
threads = []
for file in files:
thread = threading.Thread(target=file_operation, args=(file,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("ãã¹ãŠã®ãã¡ã€ã«æäœãå®äºããŸãã")
ãã«ãããã»ã¹ãéžã¶ã¹ãå Žå
- é©çšäŸ:
- 倧èŠæš¡ãªããŒã¿åŠç
- æ©æ¢°åŠç¿ã¢ãã«ã®ãã¬ãŒãã³ã°
- ç»ååŠçãæ°å€èšç®
- çç±:
GILã®å¶çŽãåé¿ããè€æ°ã®CPUã³ã¢ããã«ã«æŽ»çšããããšã§ãé«ãèšç®æ§èœãå®çŸã§ããŸãããã ããããã»ã¹éã®ããŒã¿å ±æã«ã¯æéããããå ŽåããããŸãã
ã³ãŒãäŸ: CPUè² è·ã®é«ãåŠç
from multiprocessing import Process
import time
def compute_heavy_task(task_id):
print(f"ã¿ã¹ã¯ {task_id} å®è¡äž")
time.sleep(3) ## èšç®åŠçãã·ãã¥ã¬ãŒã
print(f"ã¿ã¹ã¯ {task_id} å®äº")
tasks = ["èšç®1", "èšç®2", "èšç®3"]
processes = []
for task in tasks:
process = Process(target=compute_heavy_task, args=(task,))
processes.append(process)
process.start()
for process in processes:
process.join()
print("ãã¹ãŠã®èšç®ã¿ã¹ã¯ãå®äºããŸãã")
äž¡è ãçµã¿åãããå Žå
ç¹å®ã®ãããžã§ã¯ãã§ã¯ããã«ãã¹ã¬ãããšãã«ãããã»ã¹ãçµã¿åãããããšã§ãæé©ãªããã©ãŒãã³ã¹ãåŸãããšãã§ããŸããããšãã°ãããŒã¿ã®ååŸïŒI/OåŠçïŒããã«ãã¹ã¬ããã§äžŠååãããã®ããŒã¿ãCPUè² è·ã®é«ãèšç®ïŒãã«ãããã»ã¹ïŒã§åŠçããæ¹æ³ãèããããŸãã
ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®éžæåºæº
以äžã®ãã€ã³ããèæ ®ããŠéžæããã®ãããããã§ãã
- ã¿ã¹ã¯ã®æ§è³ª:
- I/OåŸ ã¡ãå€ãå Žå: ãã«ãã¹ã¬ãã
- èšç®äžå¿ã®ã¿ã¹ã¯ã®å Žå: ãã«ãããã»ã¹
- ãªãœãŒã¹å¶çŽ:
- ã¡ã¢ãªæ¶è²»ãæãããå Žå: ãã«ãã¹ã¬ãã
- CPUã³ã¢ãæ倧é掻çšãããå Žå: ãã«ãããã»ã¹
- ã³ãŒãã®è€éã:
- ç°¡åã«ããŒã¿ãå ±æãããå Žå: ãã«ãã¹ã¬ãã
- ããã»ã¹ééä¿¡ã«å¯Ÿå¿å¯èœãªå Žå: ãã«ãããã»ã¹

8. ãŸãšããšFAQ
Pythonã§ã®ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã®æŽ»çšã«ã€ããŠãæ¬èšäºã§ã¯åºæ¬æŠå¿µããå®è£ äŸã泚æç¹ã䜿ãåãã®ãã€ã³ããŸã§ã詳ãã解説ããŸããããã®ã»ã¯ã·ã§ã³ã§ã¯ãèšäºã®èŠç¹ããŸãšãããšãšãã«ãèªè ãæ±ããããªçåã«çããFAQ圢åŒã§è§£èª¬ãè£è¶³ããŸãã
æ¬èšäºã®èŠç¹
- ãã«ãã¹ã¬ããã®ç¹æ§
- I/OåŸ æ©æéãå¹çåããã®ã«é©ããŠãããããŒã¿ã®å ±æã容æã
- GILã®åœ±é¿ãåãããããCPUè² è·ã®é«ãåŠçã§ã¯äžåãã
- ãã«ãããã»ã¹ã®ç¹æ§
- GILã®å¶çŽãåãããCPUãå€çšããåŠçã§æ§èœãçºæ®ã
- ç¬ç«ããã¡ã¢ãªç©ºéã䜿çšãããããããã»ã¹ééä¿¡ãå¿ èŠã«ãªãå Žåãããã
- é©åãªéžæãéµ
- I/Oäžå¿ã®ã¿ã¹ã¯ã«ã¯ãã«ãã¹ã¬ããããèšç®äžå¿ã®ã¿ã¹ã¯ã«ã¯ãã«ãããã»ã¹ãéžã¶ã
- å¿ èŠã«å¿ããŠäž¡è ãçµã¿åãããããšã§æé©ãªããã©ãŒãã³ã¹ãåŸãããã
FAQïŒãããã質åïŒ
Q1: ãã«ãã¹ã¬ããã䜿çšããéãã¹ã¬ããæ°ã¯äœåãé©åã§ããïŒ
A:
ã¹ã¬ããæ°ã¯ä»¥äžãèæ
®ããŠèšå®ããã®ãè¯ãã§ãã
- I/Oäžå¿ã®åŠç:
ã¹ã¬ããæ°ãå€ãèšå®ããŠãåé¡ãããŸãããå ·äœçã«ã¯ãã¹ã¬ããæ°ãåæã«åŠçãããã¿ã¹ã¯æ°ã«åãããã®ãäžè¬çã§ãã - CPUäžå¿ã®åŠç:
ã¹ã¬ããæ°ãç©çã³ã¢æ°ä»¥äžã«æããã®ãé©åã§ããå€ããããšGILã«ããæ§èœäœäžãçºçããå¯èœæ§ããããŸãã
Q2: GILã®å¶çŽãå®å šã«åé¿ããæ¹æ³ã¯ãããŸããïŒ
A:
ã¯ãã以äžã®æ¹æ³ã§GILã®åœ±é¿ãåé¿ã§ããŸãã
- ãã«ãããã»ã¹ã®äœ¿çš:
multiprocessing
ã¢ãžã¥ãŒã«ã䜿çšããŠããã»ã¹åäœã§äžŠååŠçãè¡ãããšã§ãGILãåé¿ã§ããŸãã - å€éšã©ã€ãã©ãªã®æŽ»çš:
NumPyãPandasãªã©ã®Cèšèªã§å®è£ ãããã©ã€ãã©ãªã¯ãGILãäžæçã«è§£æŸããŠé«å¹çã«åäœããŸãã
Q3: ãã«ãã¹ã¬ãããšéåæåŠçïŒasyncioïŒã¯ã©ãéããŸããïŒ
A:
- ãã«ãã¹ã¬ãã:
ã¹ã¬ããã䜿çšããŠäžŠåã«åŠçãå®è¡ããŸããã¹ã¬ããéã§ãªãœãŒã¹ãå ±æããªããåäœãããããåæåŠçãå¿ èŠã«ãªãå ŽåããããŸãã - éåæåŠç:
asyncioã䜿çšããŠã€ãã³ãã«ãŒãå ã§ã¿ã¹ã¯ãåãæ¿ããªããå®è¡ããŸããåäžã¹ã¬ããå ã§åäœãããããã¹ã¬ããã®ç«¶åãããã¯ã®åé¡ãåé¿ã§ããŸããI/OåŸ æ©ã«ç¹åããŠãããããã¹ã¬ããããã軜éã§ãã
Q4: Pythonã§ã¹ã¬ããããŒã«ã䜿ããšã©ã®ãããªã¡ãªããããããŸããïŒ
A:
ã¹ã¬ããããŒã«ã䜿çšããããšã§ãã¹ã¬ããã®çæãçµäºãå¹çåã§ããŸããç¹ã«å€§éã®ã¿ã¹ã¯ãåŠçããå Žåã«äŸ¿å©ã§ããconcurrent.futures.ThreadPoolExecutor
ã䜿çšãããšãã¹ã¬ãã管çãç°¡åã«ãªããŸãã
äŸ:
from concurrent.futures import ThreadPoolExecutor
def task(name):
print(f"{name} å®è¡äž")
with ThreadPoolExecutor(max_workers=5) as executor:
executor.map(task, ["ã¿ã¹ã¯1", "ã¿ã¹ã¯2", "ã¿ã¹ã¯3", "ã¿ã¹ã¯4", "ã¿ã¹ã¯5"])
Q5: ãã«ãã¹ã¬ããã䜿çšãããšã¡ã¢ãªæ¶è²»éãå¢ããŸããïŒ
A:
ãã«ãã¹ã¬ããã§ã¯ãåãã¡ã¢ãªç©ºéãå
±æãããããåçŽã«ã¹ã¬ããæ°ã«æ¯äŸããŠã¡ã¢ãªæ¶è²»éãå¢ããããã§ã¯ãããŸãããããããã¹ã¬ããããšã«ã¹ã¿ãã¯ã¡ã¢ãªãå²ãåœãŠãããããã倧éã®ã¹ã¬ãããçæãããšå
šäœã®ã¡ã¢ãªäœ¿çšéãå¢å ããŸãã
çµè«
ãã«ãã¹ã¬ãããšãã«ãããã»ã¹ã¯ãPythonããã°ã©ã ã®æ§èœãåŒãåºãããã®éèŠãªææ³ã§ãããã®èšäºã®å 容ãåèã«ãããããã®ç¹æ§ã掻ãããŠãå¹ççãªäžŠååŠçãå®çŸããŠãã ãããé©åãªéžæãšèšèšã«ãããPythonããã°ã©ã ã®å¯èœæ§ãããã«åºããããšãã§ããã§ãããã