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판)
458
3
부
클래스와 프로토콜
11
.
11
.
2
_ _
slots
_ _ 문제점 정리
__slots__
는 제대로 사용하면 메모리 사용량을 엄청나게 줄일 수 있지만, 다음과 같이 주의할
점이 있다.
●
서브클래스가
__dict__
속성을 갖지 않도록 서브클래스에서도
__slots__
속성을 정의해야 한다.
●
‘__dict__’
를
__slots__
에 추가하지 않는 한 인스턴스는
__slots__
에 나열된 속성만 가질 수 있
다(
그러나
‘__dict__’
를
__slots__
에 추가하면 메모리 절감 효과가 줄어들 수 있다
).
●
__slots__
를 사용하는 클래스는 이 속성에
‘__dict__’
를 추가해야만
@cached_property
데커
레이터를 사용할 수 있다.
●
인스턴스가 약한 참조의 대상이 되려면
__slots__
에
‘__weakref__’
를 추가해야 한다.
이 장의 마지막 절인 다음 절에서는 인스턴스와 서브클래스에서 클래스 속성을 오버라이드하
는 방법을 살펴본다.
11
.
12
클래스 속성 오버라이드
클래스 속성을 객체 속성의 기본값으로 사용할 수 있다는 점은 파이썬의 독특한 특징이다.
Vector2d
클래스에는
typecode
라는 클래스 속성이 있다. 이 속성은
__bytes__
(
)
메서드
에서 두 번 사용되는데, 설계에 따라
self.typecode
로 그 값을 읽었다.
Vector2d
인스턴
스가 자신의
typecode
속성을 가지고 생성된 것이 아니므로,
self.typecode
는 기본적으로
Vector2d.typecode
클래스 속성을 ...
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