SlideShare a Scribd company logo
Generic  f unction s  in   Simon Belak [email_address] EuroPython 2006
What those not attending will miss Overview of generic functions Practical examples in TurboGears Generic functions from a framework designer’s point of view
A strange beast by the name of generic function
Generalisation of message passing Problem:  a set of abstractly the same, practically different functions Solution:  choose based on  context (e.g. arguments)
All for one,  not  one for all Single dispatch  Python, Java Multiple dispatch Type based CLOS, PyPy, Python 3000? Identity based CLOS Predicate based Cecil, Mathematica,   RuleDispatch
Pick me, pick me! Relation  more specific Arbitrary dispatch strategies
Combine and Conquer Where is my super? method chaining (dispatch strategy applies) How is this better than sliced bread? before (all applicable) after (dispatch strategy applies) around (all applicable)
Something is rotten in the package of RuleDispatch   Limited introspection Magic Scarce documentation Cryptic errors Once a generic function, always a generic function
Call now and get all these wonderful buzzwords free of charge DRY Ad-hoc event/plug-in system End-user framework extensions Data driven
Shifting to TurboGears
Use-case #1: JSON for everyone Data driven End-user framework extension
Use-case #2: errors bring joy to my heart Data driven Ad-hoc event system DRY (user and framework)
Use-case #3: not all see me equally exposed Data driven DRY
A word to the wise
RuleDispatch pitfalls Compile on definition (lexical scoping) Constant folding Solution: Limited inference
Hide but do not lock away Rule generation Hides underlying complexity Users need not know: solve the most common case implicitly Registrator pattern Adjust the scope  Always leave an out
The user takes precedence Custom dispatch strategies
Many words, few lines
The future is bright, the future is generic PEAK-Rules Python 3000?
Questions?
References peak.telecommunity.com/DevCenter/CombiningResults www.gigamonkeys.com/book/object-reorientation-generic-functions.html www.python.org/pycon/2005/papers/53/img0.html www.artima.com/weblogs/viewpost.jsp?thread=155123 codespeak.net/pypy/dist/pypy/doc/theory.html#multimethods http://citeseer.ist.psu.edu/ernst98predicate.html http://citeseer.ist.psu.edu/chambers99efficient.html

More Related Content

PPTX
1. Mini seminar intro
PDF
New sensuality
PPT
Continuations -- spletno ogrodje malo drugače
PPTX
Napadi na algoritme za strojno učenje
PDF
Zgodba o ideji
PDF
The time is out of joint: O cursed spite, / That ever I was born to set it ri...
PPT
O Filozofih In Programih
PPT
Tudi Python je lahko grd!
1. Mini seminar intro
New sensuality
Continuations -- spletno ogrodje malo drugače
Napadi na algoritme za strojno učenje
Zgodba o ideji
The time is out of joint: O cursed spite, / That ever I was born to set it ri...
O Filozofih In Programih
Tudi Python je lahko grd!

Similar to Generic functions in TurboGears (20)

PPTX
Introduction to LLM Post-Training - MIT 6.S191 2025
PPTX
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
PDF
Understanding Doctrine at True North PHP 2013
PDF
Structured Software Design
ODP
Writting Better Software
PPT
How much do we know about Object-Oriented Programming?
PPTX
Code Metrics
PPT
Oop concepts
PPT
Object Oriented Concepts and Principles
PPTX
Cloudera Data Science Challenge 3 Solution by Doug Needham
PDF
Cognizant Interview Questions By ScholarHat.pdf
PPT
chapter - 1.ppt
PPTX
Patterns of Assigning Responsibilities
PPTX
Modern C++
DOCX
Mca2030 object oriented programming – c++
PPTX
GoF Design patterns I: Introduction + Structural Patterns
ODP
PHP Barcelona 2010 - Architecture and testability
DOCX
Mca2030 object oriented programming – c++
PPTX
Logic programming in python
PPT
Generic Synchronization Policies in C++
Introduction to LLM Post-Training - MIT 6.S191 2025
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Understanding Doctrine at True North PHP 2013
Structured Software Design
Writting Better Software
How much do we know about Object-Oriented Programming?
Code Metrics
Oop concepts
Object Oriented Concepts and Principles
Cloudera Data Science Challenge 3 Solution by Doug Needham
Cognizant Interview Questions By ScholarHat.pdf
chapter - 1.ppt
Patterns of Assigning Responsibilities
Modern C++
Mca2030 object oriented programming – c++
GoF Design patterns I: Introduction + Structural Patterns
PHP Barcelona 2010 - Architecture and testability
Mca2030 object oriented programming – c++
Logic programming in python
Generic Synchronization Policies in C++
Ad

More from Simon Belak (20)

PDF
Tools for building the future
PDF
Doing data science with clojure
PDF
Exploratory analysis
PDF
Levelling up your data infrastructure
PDF
The subtle art of recommendation
PDF
Metabase Ljubljana Meetup #2
PDF
Metabase lj meetup
PDF
Sketch algorithms
PDF
Transducing for fun and profit
PDF
Your metrics are wrong
PDF
Writing smart contracts the sane way
PDF
Online statistical analysis using transducers and sketch algorithms
PDF
Save the princess
PDF
Data driven going to market strategy
PDF
Spec: a lisp-flavoured type system
PDF
A data layer in clojure
PDF
Odkrivanje segmentov iz podatkov
PDF
Using Onyx in anger
PDF
Spec + onyx
PDF
Dao of lisp
Tools for building the future
Doing data science with clojure
Exploratory analysis
Levelling up your data infrastructure
The subtle art of recommendation
Metabase Ljubljana Meetup #2
Metabase lj meetup
Sketch algorithms
Transducing for fun and profit
Your metrics are wrong
Writing smart contracts the sane way
Online statistical analysis using transducers and sketch algorithms
Save the princess
Data driven going to market strategy
Spec: a lisp-flavoured type system
A data layer in clojure
Odkrivanje segmentov iz podatkov
Using Onyx in anger
Spec + onyx
Dao of lisp
Ad

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
KodekX | Application Modernization Development
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KodekX | Application Modernization Development
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
NewMind AI Weekly Chronicles - August'25 Week I
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
Understanding_Digital_Forensics_Presentation.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Network Security Unit 5.pdf for BCA BBA.

Generic functions in TurboGears

  • 1. Generic f unction s in Simon Belak [email_address] EuroPython 2006
  • 2. What those not attending will miss Overview of generic functions Practical examples in TurboGears Generic functions from a framework designer’s point of view
  • 3. A strange beast by the name of generic function
  • 4. Generalisation of message passing Problem: a set of abstractly the same, practically different functions Solution: choose based on context (e.g. arguments)
  • 5. All for one, not one for all Single dispatch Python, Java Multiple dispatch Type based CLOS, PyPy, Python 3000? Identity based CLOS Predicate based Cecil, Mathematica, RuleDispatch
  • 6. Pick me, pick me! Relation more specific Arbitrary dispatch strategies
  • 7. Combine and Conquer Where is my super? method chaining (dispatch strategy applies) How is this better than sliced bread? before (all applicable) after (dispatch strategy applies) around (all applicable)
  • 8. Something is rotten in the package of RuleDispatch Limited introspection Magic Scarce documentation Cryptic errors Once a generic function, always a generic function
  • 9. Call now and get all these wonderful buzzwords free of charge DRY Ad-hoc event/plug-in system End-user framework extensions Data driven
  • 11. Use-case #1: JSON for everyone Data driven End-user framework extension
  • 12. Use-case #2: errors bring joy to my heart Data driven Ad-hoc event system DRY (user and framework)
  • 13. Use-case #3: not all see me equally exposed Data driven DRY
  • 14. A word to the wise
  • 15. RuleDispatch pitfalls Compile on definition (lexical scoping) Constant folding Solution: Limited inference
  • 16. Hide but do not lock away Rule generation Hides underlying complexity Users need not know: solve the most common case implicitly Registrator pattern Adjust the scope Always leave an out
  • 17. The user takes precedence Custom dispatch strategies
  • 19. The future is bright, the future is generic PEAK-Rules Python 3000?
  • 21. References peak.telecommunity.com/DevCenter/CombiningResults www.gigamonkeys.com/book/object-reorientation-generic-functions.html www.python.org/pycon/2005/papers/53/img0.html www.artima.com/weblogs/viewpost.jsp?thread=155123 codespeak.net/pypy/dist/pypy/doc/theory.html#multimethods http://citeseer.ist.psu.edu/ernst98predicate.html http://citeseer.ist.psu.edu/chambers99efficient.html