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
루시아누 하말류
,
강권학
November 2024
Beginner to intermediate
1064 pages
25h 21m
Korean
Hanbit Media, Inc.
Content preview from
전문가를 위한 파이썬(2판)
453
11
장
파이썬다운 객체
정리하면,
Vector2d
요소는 ‘비공개’ 속성이며,
Vector2d
객체는 ‘불변형’이다. 파이썬에는 비
공개 속성과 불변 속성을 정의하는 진정한 방법이 없기 때문에, 주의가 필요하다는 의미에서
따옴표를 붙였다.
이제 다시
Vector2d
클래스로 돌아가자. 다음 절에서는 객체의 내부 저장소에 영향을 미치는
특별 속성
(
메서드가 아니다
)
인
__slots__
에 관해 설명한다.
__slots__
는 클래스의 외부 인
터페이스에는 영향을 거의 미치지 않지만, 메모리 사용량에는 엄청난 영향을 미친다.
11
.
11
_
_
slots
_ _로 메모리 절약하기
기본적으로 파이썬은 객체 속성을 각 객체 안의
__dict__
라는 딕셔너리형 인스턴스 속성에 저
장한다.
3
.
9
절 ‘
dict
의 작동 방식이 미치는 영향’에서 설명했듯이, 어느 정도 최적화하고는 있
지만 여전히 메모리 사용량 부담이 상당히 크다. 그러나 속성들의 이름을 담은
__slots__
라는
클래스 속성을 정의하면 파이썬은 인스턴스 속성을 저장할 때 다른 저장소 모델을 사용한다.
__slots__
에 이름이 나온 속성들은 숨은 배열이나 참조에 저장되므로 딕셔너리보다 메모리를
적게 사용한다. [예제
11
-
13
]의 간단한 예를 통해 어떻게 작동하는지 알아보자.
예제
11-13
__
slots ...
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
전문가를 위한 리액트
테자스 쿠마르
데이터로 전문가처럼 말하기
칼 올친
개발자를 위한 머신러닝&딥러닝
로런스 모로니
고성능 파이썬(2판)
오현석, 미샤 고렐릭, 이안 오스발트
Publisher Resources
ISBN: 9791169211772