본문 바로가기

전체 글

(646)
[Dart] Class - super, this 자신의 클래스에 없으면 부모의 클래스를 찾아서 name, grade 를 출력한다. 자신의 클래스에 name, grade 변수가 있다면 super/this 키워드를 주의해서 사용할 것 void main() { Student kim = new Student(1, 'kim'); kim.who(); GradeOne lee = new GradeOne(['국어','수학','영어'], 2, 'lee'); lee.who(); print(lee.subject); lee.sayInfo(); } // 학생, 학년, 학생이름 class Student { int grade; String name; Student(this.grade, this.name); void who() { print('I am $name, grade is ..
[Dart] Class - Static void main() { // Method overriding Student.schoolName = 'Korea'; Student kim = new Student(1, 'kim'); kim.who(); } // 학생, 학교이름, 학년, 학생이름 class Student { static String? schoolName; int grade; String name; Student(this.grade, this.name); void who() { print('I am $name, grade is $grade, school name is $schoolName'); } } --------------------------------------------[result] I am kim, grade is 1, scho..
[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) - Futures(1) Futures 동시성 비동기 작업 실행 지연시간(Block) CPU 및 리소스 낭비 방지 -> (File)Network I/O 관련 작업 -> 동시성 활용 권장 비동기 작업과 적합한 프로그램일 경우 압도적으로 성능 향상 futures : 비동기 실행을 위한 API를 고수준으로 작성 -> 사용하기 쉽도록 개선 concurrent.Futures 1. 멀티스레딩/멀티프로세싱 API 통일 -> 매우 사용하기 쉬움 2. 실행중이 작업 취소, 완료 여부 체크, 타임아웃 옵션, 콜백추가, 동기화 코드 매우 쉽게 작성 -> Promise 개념 GIL : 두 개 이상의 스레드가 동시에 실행 될 때 하나의 자원을 엑세스 하는 경우 -> 문제점을 방지하기 위해 GIL 실행 , 리소스 전체에 락이 걸린다. -> Context..