Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
고성능 파이썬(2판)
by
오현석
,
미샤 고렐릭
,
이안 오스발트
May 2021
Beginner to intermediate
528 pages
11h 27m
Korean
Hanbit Media, Inc.
Content preview from
고성능 파이썬(2판)
131
5
장
이터레이터와 제너레이터
이 장에서 배울 내용
•
제너레이터에서 메모리를 절약하는 방법
•
제너레이터가 유용한 상황
•
복잡한 제너레이터 작업에
itertools
를 사용하는 방법
•
지연 연산이 효과적인 경우와 그렇지 않은 경우
다른 프로그래밍 언어에 익숙한 사람들이 파이썬을 처음 접하면 파이썬의
for
루프 표기법에
놀라곤 한다. 다른 언어의 루프는 보통 다음과 같은 형태다.
# 다른 언어
for
(i=0; i<N; i++) {
do_work(i);
}
파이썬에서는
range
라는 새로운 함수를 도입했다.
# 파이썬
for
i
in
range(N):
do_work(i)
이터레이터와 제너레이터
CHAPTER
5
132
고성능 파이썬(2판)
이 파이썬 코드는 루프가 지속되는 데 필요한 모든 데이터를 만들어내는
range
라는 함수를 호
출하는 것처럼 보인다. 직관적으로 생각해보면,
1
부터
1
억까지 수를 세려고 항목이
1
억 개인
배열을 만들어야 한다면 시간이 오래 걸리고 메모리도 많이 필요할 것이다. 여기서
제너레이터
generator
가 위력을 발휘한다. 제너레이터를 사용하면 이런 종류의 함수를
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
이펙티브 타입스크립트
Dan Vanderkam
전문가를 위한 파이썬(2판)
루시아누 하말류
엑셀이 편해지는 파이썬
펠릭스 춤슈타인
핸즈온 비지도 학습
강재원, 권재철, 안쿠르 A. 파텔
Publisher Resources
ISBN: 9791162244210