SlideShare a Scribd company logo
1 of 20
Download to read offline
Python’s
Dynamic Nature
An investigation of how Python’s dynamic nature
allows it to scale up from one-line scripts to massive
applications.
Kiran Jonnalagadda <jace@seacrow.com>
These are rough slides. The finals will make heavy use
of diagrams in place of text.
What Does
Interpreted Mean?
• Python is not line interpreted like shell
script.

• Python is byte-code compiled like Java,
but compilation is on-the-fly.

• However, Python in some ways behaves
like a line-interpreted language, making
the learning curve easy.
Loading a Module
• When a module (file) is loaded, it is first
compiled into byte-code.

• Python then executes all the code in the
module that is not in a function.

• This code can modify the module as it

loads, making for the line-interpreted feel.

• Code in functions is only executed on call.
Example of Loading
# Example code
print “Top level executes on load.”
def somefunc():
print “Executes only when called.”
class foo:
print “Class level also executes on load.”
def bar(self):
print “Executes only when called.”
Bags of Attributes
• Python is a fully object oriented language.
• All symbols are objects with attributes.
• Objects contain other objects. Therefore,
Python’s namespace is nested.

• A module is an object, a string is an

object, an integer is an object, everything
is an object.
__attributes__
• Python inserts several special attributes
into objects. These attributes are all
named in the __attribute__ style.

• Example 1: __name__ indicates the name
given to the object in code.

• Example 2: __class__ refers to the class
this object is an instance of.
Operator Overloading
• Operator overloading is also achieved via
functions with special attribute names.

• Examples:
• __eq__ and __ne__ for == and !=
• __add__ to add two objects
• __cmp__ to compare, for sorting
Controlling Attribute
Access

• An object can take control of the way its
attributes are accessed.

• The __getitem__ function for list or

dictionary access. Example: object[‘foo’]

• The __getattr__ function for named

access. Example: using object.foo will call
object.__getattr__(‘foo’)

• __setitem__ and __setattr__ for editing.
Documentation
• Python code is self-documenting.
• Documentation can be placed in a string,

which must be the first non-remark
declaration in a module, class or function.

• This documentation is accessible as the
__doc__ attribute of the object.

• Example:

class foo:
“This is the documentation.”
pass
Namespaces
• In Python, everything is contained within
something else.

• The top-level, invisible container is called
__builtins__. Contains internal functions.

• Top-level symbols not from __builtins__
are local symbols.

• Local symbols are not private. They can
be accessed via the namespace.
Namespaces #2
• The top-level namespace is not crowded;

an app can have several modules with
conflicting names and not have a conflict.

• “module1.cname” is different from
“module2.cname”

• Using “name = module1.cname” makes

“name” a local alias for “module1.cname”
Symbols and Objects
• Symbols are not the same as objects.
• Symbols are only references to objects.
• An object can have multiple references.
• Objects are garbage collected when they

have zero references. GC algorithms used
are both reference counting and markand-sweep.
Multiple References
• An module can consist of nothing but

references to symbols in other modules.

• Hence the term, “bags of attributes.”
• This allows a large package to have a

single API module that links to the rest of
the package internally.
References Example
module1.py:
def foo(bar, baz):
return bar + baz

module2.py:
import module1
new_name = module1.foo

module3.py:
from module2 import new_name
print new_name(1, 2)
Runtime Editing
• Python code can edit itself at run-time.
• The only way to define variables in a class
is by editing the instance at runtime.

• Editing involves simply changing the
object a symbol refers to.

• This only works when all code refers to
the object via the symbol, which is the
case almost all the time.
How Classes Work
• {To insert code examples and diagram

here, showing a complex class definition
and how it works when different parts are
accessed. This will be across several
slides.}
Scalability
• Because of the clear namespace

separation, a Python application can
contain thousands of modules without
conflicts.

• Advanced class definition ability helps
avoid repetitive code.

• This makes Python code easy to maintain
and scale, while still remaining simple.
The Type/Class
Dichotomy

• Prior to version 2.2, Python had two
types of objects: Types and Classes.

• Types could only be defined in C code.
• Classes could only be defined in Python.
• Classes could not be derived from Types.
• This meant a base-class could not be
defined externally in C/C++ code.
Zope’s Solution
• Jim Fulton, the creator of Zope, created a
new Type called ExtensionClass.

• ExtensionClass can be derived from, like
a regular Python Class, but is a Type.

• Achieved by patching Python internals.
• ExtensionClass made a lot of extensions

possible that could not be done in Python.
Type/Class Merger
• Python 2.2 merges Types and Classes, so
they are all one type of object.

• But changes are incompatible with

ExtensionClass, which Zope depends on.

• So Zope still uses the old Type/Class

divide, even with Python 2.2 and 2.3.

• Zope will upgrade with Zope 3.

More Related Content

What's hot

C++ to java
C++ to javaC++ to java
C++ to javaAjmal Ak
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building BlocksCate Huston
 
Thinking Like a Programmer
Thinking Like a ProgrammerThinking Like a Programmer
Thinking Like a ProgrammerCate Huston
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noiseNeeraj Bhusare
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with javaMohamed Fathy
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developersMohamed Wael
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Muhammad Haseeb Shahid
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with XtendSven Efftinge
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to ClojureRenzo Borgatti
 
Ruby Presentation
Ruby Presentation Ruby Presentation
Ruby Presentation platico_dev
 
java training in jaipur|java training|core java training|java training compa...
 java training in jaipur|java training|core java training|java training compa... java training in jaipur|java training|core java training|java training compa...
java training in jaipur|java training|core java training|java training compa...infojaipurinfo Jaipur
 

What's hot (20)

C++ to java
C++ to javaC++ to java
C++ to java
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
 
Thinking Like a Programmer
Thinking Like a ProgrammerThinking Like a Programmer
Thinking Like a Programmer
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Virtual Function
Virtual FunctionVirtual Function
Virtual Function
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with java
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
C++vs java
C++vs javaC++vs java
C++vs java
 
CORBA & RMI in java
CORBA & RMI in javaCORBA & RMI in java
CORBA & RMI in java
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
 
Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2
 
C sharp
C sharpC sharp
C sharp
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
 
Presentation On Com Dcom
Presentation On Com DcomPresentation On Com Dcom
Presentation On Com Dcom
 
Ruby Presentation
Ruby Presentation Ruby Presentation
Ruby Presentation
 
Corba by Example
Corba by ExampleCorba by Example
Corba by Example
 
java training in jaipur|java training|core java training|java training compa...
 java training in jaipur|java training|core java training|java training compa... java training in jaipur|java training|core java training|java training compa...
java training in jaipur|java training|core java training|java training compa...
 

Viewers also liked (20)

Final ppt of gd
Final ppt of gdFinal ppt of gd
Final ppt of gd
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Group Dynamics
Group DynamicsGroup Dynamics
Group Dynamics
 
Groups within society
Groups within societyGroups within society
Groups within society
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
Types of Social Groups
Types of Social GroupsTypes of Social Groups
Types of Social Groups
 
ppt of group dynamics
ppt of group dynamicsppt of group dynamics
ppt of group dynamics
 
Danny Maribao_Lesson 3-conformity and obedience
Danny Maribao_Lesson 3-conformity and obedienceDanny Maribao_Lesson 3-conformity and obedience
Danny Maribao_Lesson 3-conformity and obedience
 
Social groups and types
Social groups and typesSocial groups and types
Social groups and types
 
Are You Listening? The Importance Of Social Media Monitoring
Are You Listening? The Importance Of Social Media MonitoringAre You Listening? The Importance Of Social Media Monitoring
Are You Listening? The Importance Of Social Media Monitoring
 
Youth for christ talk 3
Youth for christ talk 3Youth for christ talk 3
Youth for christ talk 3
 
Importance of group communication
Importance of group communicationImportance of group communication
Importance of group communication
 
Group dynamics
Group dynamicsGroup dynamics
Group dynamics
 
group norms
group normsgroup norms
group norms
 
Group dynamics and Ethics
Group dynamics and EthicsGroup dynamics and Ethics
Group dynamics and Ethics
 

Similar to Python's dynamic nature (rough slides, November 2004)

UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csjaved75
 
Python for katana
Python for katanaPython for katana
Python for katanakedar nath
 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptxrayanbabur
 
Owner - Java properties reinvented.
Owner - Java properties reinvented.Owner - Java properties reinvented.
Owner - Java properties reinvented.Luigi Viggiano
 
A peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserA peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserKoan-Sin Tan
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaiUnmesh Baile
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaivibrantuser
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Andrei KUCHARAVY
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not JavaChris Adamson
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
 
Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsAndrew McNicol
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 

Similar to Python's dynamic nature (rough slides, November 2004) (20)

UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
 
Python for katana
Python for katanaPython for katana
Python for katana
 
full defination of final opp.pptx
full defination of final opp.pptxfull defination of final opp.pptx
full defination of final opp.pptx
 
Owner - Java properties reinvented.
Owner - Java properties reinvented.Owner - Java properties reinvented.
Owner - Java properties reinvented.
 
A peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserA peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk User
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Java
JavaJava
Java
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Java
JavaJava
Java
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not Java
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security Professionals
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 

More from Kiran Jonnalagadda

AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)Kiran Jonnalagadda
 
The medium without the message (April 2008)
The medium without the message (April 2008)The medium without the message (April 2008)
The medium without the message (April 2008)Kiran Jonnalagadda
 
Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)Kiran Jonnalagadda
 
Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)Kiran Jonnalagadda
 
What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)Kiran Jonnalagadda
 
On blogging as a career (June 2005)
On blogging as a career (June 2005)On blogging as a career (June 2005)
On blogging as a career (June 2005)Kiran Jonnalagadda
 
Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Kiran Jonnalagadda
 
Human database relations (March 2004)
Human database relations (March 2004)Human database relations (March 2004)
Human database relations (March 2004)Kiran Jonnalagadda
 
The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)Kiran Jonnalagadda
 
Introduction to Plone (November 2003)
Introduction to Plone (November 2003)Introduction to Plone (November 2003)
Introduction to Plone (November 2003)Kiran Jonnalagadda
 
ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)Kiran Jonnalagadda
 
Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Kiran Jonnalagadda
 
e-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introductione-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introductionKiran Jonnalagadda
 

More from Kiran Jonnalagadda (17)

AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)
 
The medium without the message (April 2008)
The medium without the message (April 2008)The medium without the message (April 2008)
The medium without the message (April 2008)
 
Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)
 
Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)
 
What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)
 
On blogging as a career (June 2005)
On blogging as a career (June 2005)On blogging as a career (June 2005)
On blogging as a career (June 2005)
 
Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)Python and Zope: An introduction (May 2004)
Python and Zope: An introduction (May 2004)
 
Human database relations (March 2004)
Human database relations (March 2004)Human database relations (March 2004)
Human database relations (March 2004)
 
The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)
 
Introduction to Plone (November 2003)
Introduction to Plone (November 2003)Introduction to Plone (November 2003)
Introduction to Plone (November 2003)
 
ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)
 
User Management with LastUser
User Management with LastUserUser Management with LastUser
User Management with LastUser
 
Sustainability and bit-rot
Sustainability and bit-rotSustainability and bit-rot
Sustainability and bit-rot
 
e-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introductione-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introduction
 
Cyberpunk Sci-Fi
Cyberpunk Sci-FiCyberpunk Sci-Fi
Cyberpunk Sci-Fi
 

Recently uploaded

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Python's dynamic nature (rough slides, November 2004)

  • 1. Python’s Dynamic Nature An investigation of how Python’s dynamic nature allows it to scale up from one-line scripts to massive applications. Kiran Jonnalagadda <jace@seacrow.com> These are rough slides. The finals will make heavy use of diagrams in place of text.
  • 2. What Does Interpreted Mean? • Python is not line interpreted like shell script. • Python is byte-code compiled like Java, but compilation is on-the-fly. • However, Python in some ways behaves like a line-interpreted language, making the learning curve easy.
  • 3. Loading a Module • When a module (file) is loaded, it is first compiled into byte-code. • Python then executes all the code in the module that is not in a function. • This code can modify the module as it loads, making for the line-interpreted feel. • Code in functions is only executed on call.
  • 4. Example of Loading # Example code print “Top level executes on load.” def somefunc(): print “Executes only when called.” class foo: print “Class level also executes on load.” def bar(self): print “Executes only when called.”
  • 5. Bags of Attributes • Python is a fully object oriented language. • All symbols are objects with attributes. • Objects contain other objects. Therefore, Python’s namespace is nested. • A module is an object, a string is an object, an integer is an object, everything is an object.
  • 6. __attributes__ • Python inserts several special attributes into objects. These attributes are all named in the __attribute__ style. • Example 1: __name__ indicates the name given to the object in code. • Example 2: __class__ refers to the class this object is an instance of.
  • 7. Operator Overloading • Operator overloading is also achieved via functions with special attribute names. • Examples: • __eq__ and __ne__ for == and != • __add__ to add two objects • __cmp__ to compare, for sorting
  • 8. Controlling Attribute Access • An object can take control of the way its attributes are accessed. • The __getitem__ function for list or dictionary access. Example: object[‘foo’] • The __getattr__ function for named access. Example: using object.foo will call object.__getattr__(‘foo’) • __setitem__ and __setattr__ for editing.
  • 9. Documentation • Python code is self-documenting. • Documentation can be placed in a string, which must be the first non-remark declaration in a module, class or function. • This documentation is accessible as the __doc__ attribute of the object. • Example: class foo: “This is the documentation.” pass
  • 10. Namespaces • In Python, everything is contained within something else. • The top-level, invisible container is called __builtins__. Contains internal functions. • Top-level symbols not from __builtins__ are local symbols. • Local symbols are not private. They can be accessed via the namespace.
  • 11. Namespaces #2 • The top-level namespace is not crowded; an app can have several modules with conflicting names and not have a conflict. • “module1.cname” is different from “module2.cname” • Using “name = module1.cname” makes “name” a local alias for “module1.cname”
  • 12. Symbols and Objects • Symbols are not the same as objects. • Symbols are only references to objects. • An object can have multiple references. • Objects are garbage collected when they have zero references. GC algorithms used are both reference counting and markand-sweep.
  • 13. Multiple References • An module can consist of nothing but references to symbols in other modules. • Hence the term, “bags of attributes.” • This allows a large package to have a single API module that links to the rest of the package internally.
  • 14. References Example module1.py: def foo(bar, baz): return bar + baz module2.py: import module1 new_name = module1.foo module3.py: from module2 import new_name print new_name(1, 2)
  • 15. Runtime Editing • Python code can edit itself at run-time. • The only way to define variables in a class is by editing the instance at runtime. • Editing involves simply changing the object a symbol refers to. • This only works when all code refers to the object via the symbol, which is the case almost all the time.
  • 16. How Classes Work • {To insert code examples and diagram here, showing a complex class definition and how it works when different parts are accessed. This will be across several slides.}
  • 17. Scalability • Because of the clear namespace separation, a Python application can contain thousands of modules without conflicts. • Advanced class definition ability helps avoid repetitive code. • This makes Python code easy to maintain and scale, while still remaining simple.
  • 18. The Type/Class Dichotomy • Prior to version 2.2, Python had two types of objects: Types and Classes. • Types could only be defined in C code. • Classes could only be defined in Python. • Classes could not be derived from Types. • This meant a base-class could not be defined externally in C/C++ code.
  • 19. Zope’s Solution • Jim Fulton, the creator of Zope, created a new Type called ExtensionClass. • ExtensionClass can be derived from, like a regular Python Class, but is a Type. • Achieved by patching Python internals. • ExtensionClass made a lot of extensions possible that could not be done in Python.
  • 20. Type/Class Merger • Python 2.2 merges Types and Classes, so they are all one type of object. • But changes are incompatible with ExtensionClass, which Zope depends on. • So Zope still uses the old Type/Class divide, even with Python 2.2 and 2.3. • Zope will upgrade with Zope 3.