본문 바로가기

분류 전체보기

(668)
[Dart] Class - Method override Method override & super kewword void main() { // Method overriding Parent parent = new Parent(3); Child child = new Child(3); print('parent.cal():' + parent.cal().toString()); print('child.cal():' + child.cal().toString()); } class Parent { final int _number; Parent(this._number); int cal() { return this._number * this._number; } } class Child extends Parent { Child(int number) : super(number); ..
[Dart] Class - 상속/Inheritance void main() { House house1 = new House(4, 2); house1.aboutFloors(); house1.aboutRooms(); print('------------- APT -------------'); Apt apt1 = new Apt(5, 3, 'Rome'); apt1.aboutFloors(); apt1.aboutRooms(); apt1.aboutName(); print('------------- Villa -------------'); Villa villa1 = new Villa(1, 2, 'Milano'); villa1.aboutFloors(); villa1.aboutRooms(); villa1.aboutName(); } class House { // private ..
[Dart] Class - getter, setter void main() { House house1 = new House(4,2); house1.aboutHouse(); print(house1.rooms); house1.rooms = 10; house1.aboutHouse(); } class House { // private variable int _rooms; int _floors; House(this._rooms, this._floors); void aboutHouse(){ print('This house has $_floors floors and $_rooms rooms.'); } int get rooms{ return this._rooms; } set rooms(int room){ this._rooms = room; } } -------------..
[Dart] Class - 선언 및 생성자 선언 및 생성자 void main() { House house1 = new House(4,2); house1.aboutHouse(); } class House { final int? rooms; final int? floors; House(this.rooms, this.floors); void aboutHouse(){ print('This house has $floors floors and $rooms rooms.'); } } --------------------------------------------[result] This house has 2 floors and 4 rooms. 다른 스타일 생성자 void main() { House house1 = new House(4,2); house1.abou..
[Python] 병행성(Concurrency) - Futures(2) 2가지 패턴 실습 concurrent.futures - wait, as_completed import os import time from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, wait, as_completed WORK_LIST = [100000000, 10000000, 1000000, 100000] # 동시성 합계 계산 메인 함수 # 누적 합계 함수(제레네이터) def sum_generator(n): return sum(n for n in range(1, n+1)) # wait - 모든 작업이 끝날때까지 기다림 # as_completed - 먼저 끝난 작업결과를 반환함 def main(): # Worker Count wor..
[Python] 병행성(Concurrency)(4) - Futures(1) Futures 동시성비동기 작업 실행지연시간(Block) CPU 및 리소스 낭비 방지 -> (File)Network I/O 관련 작업 -> 동시성 활용 권장비동기 작업과 적합한 프로그램일 경우 압도적으로 성능 향상 futures : 비동기 실행을 위한 API를 고수준으로 작성 -> 사용하기 쉽도록 개선concurrent.Futures1. 멀티스레딩/멀티프로세싱 API 통일 -> 매우 사용하기 쉬움2. 실행중이 작업 취소, 완료 여부 체크, 타임아웃 옵션, 콜백추가, 동기화 코드 매우 쉽게 작성 -> Promise 개념 2가지 패턴 실습# concurrent.futures 사용법1# concurrent.futures 사용법2 GIL : 두 개 이상의 스레드가 동시에 실행 될 때 하나의 자원을 엑세스 하는 ..
[Python] 병행성(Concurrency)(3) - Coroutine 흐름제어 병행성(Concurrency) : 한 컴퓨터가 여러 일을 동시에 수행 -> 단일 프로그램안에서 여러일을 쉽게 해결 병렬성(Parallelism) : 여러 컴퓨터가 여러 작업을 동시에 수행 -> 속도 코루틴(Coroutine) : 단일(싱글) 스레드, 스택을 기반으로 동작하는 비동기 작업 스레드 : OS 관리, cpu 코어에서 실시간, 시분할 비동기 작업 -> 멀티스레드 yield, send : 메인 서브 코루틴 제어, 상태, 양방향 전송 yield from 서브루틴 : 메인루틴에서 호출 -> 서브루틴에서 수행(흐름제어) 코루틴 : 루틴 실행 중 중지 -> 동시성 프로그래밍 코루틴 : 스레드에 비해 오버헤드 감소 스레드 : 싱글스레드 -> 멀티스레드 -> 복잡 -> 공유되는 자원 -> 교착 상태..
[Python] 병행성(Concurrency)(2) - generator # 병렬성(Parallelism) : 여러 컴퓨터가 여러 작업을 동시에 수행 -> 속도# 병행성(Concurrency) : 한 컴퓨터가 여러일을 동시에 수행# -> 단일 프로그램 안에서 여러일을 쉽게 해결# 이터레이터, 제네레이터# Iterator, Generator# 파이썬 반복 가능한 타입# for, collections, text file, List, Dict, Set, Tuple, unpacking, *args Iterator, Generator - 값을 차례대로 가져올 수 있음 ✅ Iterator (이터레이터)"하나씩 값을 꺼낼 수 있는 객체"__iter__()와 __next__() 메서드를 가진 객체for 문, next() 함수와 함께 사용 가능값을 직접 기억하고 관리함 (내부 상태) ✅ G..