컴퓨터/파이썬
-
Python: MPIRE 파이썬 멀티 프로세싱 라이브러리컴퓨터/파이썬 2022. 1. 16. 19:33
MPIRE GitHub - Slimmer-AI/mpire A Python package for easy multiprocessing, but faster than multiprocessing github.com 소개 GIL 때문에 멀티 스레딩이 다른 언어와 같이 작동을 안 하는 파이썬 기본 탑재된 multiprocessing.Pool이나 concurrent.futures.ProcessPoolExecutor와 같은 클래스들을 이용하여 멀티 프로세싱/스레딩을 사용할 수 있는 데 사용하기 어려울 수 있다. MPIRE (MultiProcessing Is Really Easy, 멀티프로세싱 정말 쉬움) 라이브러리를 이용하여 쉽게 구현할 수 있다. 이 라이브러리는 멀티프로세싱 기본 라이브러리 기반이라 문법이 거의 ..
-
Python: Mito 파이썬 데이터 분석 라이브러리컴퓨터/파이썬 2022. 1. 15. 20:32
Mito Mito Documentation - Mito Welcome to the documentation for Mito. Mito is a spreadsheet that helps you complete your Python analyses 10x faster. You edit the Mitosheet, and it generates Python code for you. To quickly get started, see the links below: docs.trymito.io 소개 Mito 라이브러리는 데이터 전처리, 분석, 변형 등을 GUI로 통해서 하게 도와주는데 자동으로 Python 코드까지 생성해준다는 게 특징이다. (MS Excel, Bamboolib과 비슷한 듯) pandas를 이용할 수..
-
Python: 사진 to pdf 파일 변환컴퓨터/파이썬 2021. 10. 23. 23:56
사진 파일들을 pdf에 담을 간단한 작업이 자주 필요했다. 아래를 실행하면 원하는 사진들이 "~~. pdf"로 저장된다. 사용법 pdf.py에 코드를 저장하고 argument를 전달한다. -f (필수) 뒤 사진들 | -p (옵션) 저장할 경로 | -n (옵션) 원하는 pdf 이름 # 사용법 python pdf.py -f 1.jpg E:\2.jpg python pdf.py -f 1.jpg E:\2.jpg -p "E:\" pdf.py from argparse import ArgumentParser from PIL import Image import os import random # 기본 저장되는 경로 PATH = "C:\\Users\\user\\Desktop\\" if __name__ == "__main__..
-
Python: 간단한 streamlit 앱 만들면서 배운 점컴퓨터/파이썬 2021. 9. 19. 14:34
streamlit 만든 것 데이터 앱을 쉽고 예쁘게 만들 수 있는 streamlit, mongoDB 필터링 기능도 익힐 겸 아래의 값들에 따라 필터링을 해서 테이블을 업데이트한다. (자동으로 공지들을 db에 저장하고 있다.) 구조 처음에 st.slider, st.multiselect 와 같은 위젯들 on_change에 callback 함수를 추가해서 그 함수에서 값들을 받고, 필터를 만들고, global 테이블을 업데이트했다. st.title("title") my_table = st.empty() def update_notice(): global my_table global categories my_table.empty() filter = {} try: # whenever I change category..
-
FastAPI + discord.py snippet컴퓨터/파이썬 2021. 8. 24. 09:31
FastAPI 서버와 discord.py 서버를 같이 실행시키고 싶었다. unvicorn.run 한 후에 startUp 함수에서 bot.start를 하는 방법도 있었는데 자꾸 봇이 offline으로 가게 되었다. Python import discord from discord.ext import commands from fastapi import FastAPI from uvicorn import Config, Server TOKEN = "토큰" intents = discord.Intents.all() bot = commands.Bot(command_prefix="#", intents=intents) @bot.event async def on_message(message): if message.content..
-
Python Selenium: 여러가지 팁컴퓨터/파이썬 2021. 6. 7. 16:25
1. 크롬 드라이버를 알아서 다운로드해서 설정 이유: 셀레니움을 이용한 콘솔 앱을 만들었는데 chrome이 업데이트된 후에 정상적으로 작동하지 않음 webdriver-manager를 이용해서 알아서 다운로드 시킨다. (크롬, firefox, IE, edge를 지원함) pip install webdriver-manager 예제 import os import sys from selenium import webdriver from selenium.webdriver.chrome.options import Options from webdriver_manager.chrome import ChromeDriverManager def resource_path(another_way): try: usual_way = ( s..
-
Pyston: Python 3.8.8 최적화 버전컴퓨터/파이썬 2021. 5. 9. 21:17
pyston pyston/pyston A faster and highly-compatible implementation of the Python programming language. - pyston/pyston github.com 소개 아직은 linux 계열밖에 사용 못한다. 특징은 다음과 같다. (+ pip-pyston으로 python의 모든 모듈과 호환됨) (리얼 프로덕션에서 30% 성능 향상을 볼 수 있다고 소개되어있다.) - A very-low-overhead JIT using DynASM - Quickening (인터프리터 효율적으로 하는 방법) - Aggressive attribute caching - General CPython optimizations - Build process impr..
-
Python: Generic 함수 만들기 (functools.singledispatch)컴퓨터/파이썬 2021. 4. 7. 21:34
functools 1. 소개 fastcore를 소개했을 때 Julia 언어의 멀티 디스패치 기능을 소개했었는데 Python fastcore: 파이썬 업그레이드 모듈 fastcore fast.ai fastcore Github 링크 github.com fast.ai에서 제작한 파이썬 언어 확장 모듈 1. 소개 fastcore은 Julia 언어의 multiple dispatch, Ruby 언어의 mixins, Haskell 언어의 currying, binding 등.. www.seokdev.site 기본 모듈에서 싱글 디스패치 제너릭 함수를 지원하는지 몰랐다. (3.4+ 이상부터 지원) 파이썬에서는 타입을 신경 쓰진 않지만 3.7+이상부턴 타입 힌트를 써주는 게 convention이 된 것 같다. 코드를 깔끔..