The document discusses metaclasses and bytecode in Python from the perspective of a Smalltalk user. Smalltalk influenced Python's use of bytecode, though Python's metaclasses differ from Smalltalk. Metaclasses in Smalltalk determine the class of a class, with every class being an instance of its metaclass. In Python, the default metaclass is type, but some standard classes use non-type metaclasses defined in the abc module. The document also provides an overview of Smalltalk bytecode categories and examples, and compares it to the Python bytecode generated for simple methods.
Mon, August 22, 2:00pm – 2:30pm
Youtube: https://youtu.be/OlJZMHLTfuc
Description
Abstract: Spur is the new memory manager for the Cog virtual machine used by Pharo, Newspeak and Squeak. It features a two generation scavenger garbage collector with an adaptative tenuring policy, lazy become, (transparent) segmented memory, a new 64bit-compatible object-format, ephemerons, pinned objects, a class table, among others. If you're high-level application developer, or a programming amateur, but not a VM expert, but you're interested in understanding these concepts and what is their impact on your day to day development this talk is for you.
Bio: Guille Polito is research engineer at CNRS, France. Pharoer since 2010, he participates actively in the Pharo open source community since several years. He currently works on the modularization of Pharo where he does software archeology, refactoring, library rewriting and participates in the Virtual Machine development.
Repeating History...On Purpose...with ElixirBarry Jones
A dive into the highlights of Elixir that make it the ideal platform for the web...and how all these questions were answered figured out 30 years ago. Presented to Upstate Elixir in Greenville, SC on Nov 16.
This is the presentation I gave about Python 3.5 to my research group. It was my intention to introduce the Python language to some of the new members who don't know or have little knowledge about the language.
Mon, August 22, 2:00pm – 2:30pm
Youtube: https://youtu.be/OlJZMHLTfuc
Description
Abstract: Spur is the new memory manager for the Cog virtual machine used by Pharo, Newspeak and Squeak. It features a two generation scavenger garbage collector with an adaptative tenuring policy, lazy become, (transparent) segmented memory, a new 64bit-compatible object-format, ephemerons, pinned objects, a class table, among others. If you're high-level application developer, or a programming amateur, but not a VM expert, but you're interested in understanding these concepts and what is their impact on your day to day development this talk is for you.
Bio: Guille Polito is research engineer at CNRS, France. Pharoer since 2010, he participates actively in the Pharo open source community since several years. He currently works on the modularization of Pharo where he does software archeology, refactoring, library rewriting and participates in the Virtual Machine development.
Repeating History...On Purpose...with ElixirBarry Jones
A dive into the highlights of Elixir that make it the ideal platform for the web...and how all these questions were answered figured out 30 years ago. Presented to Upstate Elixir in Greenville, SC on Nov 16.
This is the presentation I gave about Python 3.5 to my research group. It was my intention to introduce the Python language to some of the new members who don't know or have little knowledge about the language.
JSON, by now, became a regular part of most applications and services. Do we, how ever, really want to transfer human readable information or are we looking for a binary protocol to be as debuggable as JSON? CBOR the Concise Binary Object Representation offers the best of JSON + an extremely efficient, binary representation.
http://www.cbor.io
A short introduction to the more advanced python and programming in general. Intended for users that has already learned the basic coding skills but want to have a rapid tour of more in-depth capacities offered by Python and some general programming background.
Execrices are available at: https://github.com/chiffa/Intermediate_Python_programming
Can we move beyond threads and locks to manage concurrency? Are there more advanced models than threads and locks? How do other languages manage the concurrency?
We see some examples in others languages and a possible solution in C++.
Example code: https://github.com/italiancpp/meetup-milano-2014/tree/master/cpp_actor_model
Aim of this presentation is not to make you masters in Java 8 Concurrency, but to help you guide towards that goal. Sometimes it helps just to know that there is some API that might be suitable for a particular situation. Make use of the pointers given to search more and learn more on those topics. Refer to books, Java API Documentation, Blogs etc. to learn more. Examples and demos for all cases discussed will be added to my blog www.javajee.com.
Introduction about Python by JanBask Training, we are offering Online Pyton Training. You should visit: http://www.janbasktraining.com/python/ for Pyton Training.
Machine Learning on Your Hand - Introduction to Tensorflow Lite PreviewModulabs
TF Dev Summit × Modulabs : Learn by Run !
Machine Learning on Your Hand - Introduction to Tensorflow Lite Preview (발표자 : 강재욱)
※ 모두의연구소 페이지 : https://www.facebook.com/lab4all/
※ 모두의연구소 커뮤니티 그룹 : https://www.facebook.com/groups/modulabs
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Holden Karau
TensorFlow is all kinds of fancy, from helping startups raising their series A in Silicon Valley to detecting if something is a cat. However, when things start to get “real,” you may find yourself no longer just dealing with mnist.csv but instead needing do large-scale data prep as well as training.
Holden Karau details how to use TensorFlow in conjunction with Apache Spark, Flink, and Beam to create a full machine learning pipeline—including the annoying feature engineering and data prep components that we like to pretend don’t exist. Holden also explains why these feature prep stages need to be integrated into the serving layer. She concludes by examining changing industry trends, like Apache Arrow, and how they impact cross-language development for things like deep learning. Even if you’re not trying to raise a round of funding in Silicon Valley, this talk will give you tools to do interesting machine learning problems at scale.
Powerpoint realizado por la niña de 10 años Paula del Valle para explicar el trabajo del investigador Oriol Mitjà contra la enfermedad de pian a su clase del colegio Nuestra Señora de la Consolación (Benicarló).
JSON, by now, became a regular part of most applications and services. Do we, how ever, really want to transfer human readable information or are we looking for a binary protocol to be as debuggable as JSON? CBOR the Concise Binary Object Representation offers the best of JSON + an extremely efficient, binary representation.
http://www.cbor.io
A short introduction to the more advanced python and programming in general. Intended for users that has already learned the basic coding skills but want to have a rapid tour of more in-depth capacities offered by Python and some general programming background.
Execrices are available at: https://github.com/chiffa/Intermediate_Python_programming
Can we move beyond threads and locks to manage concurrency? Are there more advanced models than threads and locks? How do other languages manage the concurrency?
We see some examples in others languages and a possible solution in C++.
Example code: https://github.com/italiancpp/meetup-milano-2014/tree/master/cpp_actor_model
Aim of this presentation is not to make you masters in Java 8 Concurrency, but to help you guide towards that goal. Sometimes it helps just to know that there is some API that might be suitable for a particular situation. Make use of the pointers given to search more and learn more on those topics. Refer to books, Java API Documentation, Blogs etc. to learn more. Examples and demos for all cases discussed will be added to my blog www.javajee.com.
Introduction about Python by JanBask Training, we are offering Online Pyton Training. You should visit: http://www.janbasktraining.com/python/ for Pyton Training.
Machine Learning on Your Hand - Introduction to Tensorflow Lite PreviewModulabs
TF Dev Summit × Modulabs : Learn by Run !
Machine Learning on Your Hand - Introduction to Tensorflow Lite Preview (발표자 : 강재욱)
※ 모두의연구소 페이지 : https://www.facebook.com/lab4all/
※ 모두의연구소 커뮤니티 그룹 : https://www.facebook.com/groups/modulabs
Powering Tensorflow with big data using Apache Beam, Flink, and Spark - OSCON...Holden Karau
TensorFlow is all kinds of fancy, from helping startups raising their series A in Silicon Valley to detecting if something is a cat. However, when things start to get “real,” you may find yourself no longer just dealing with mnist.csv but instead needing do large-scale data prep as well as training.
Holden Karau details how to use TensorFlow in conjunction with Apache Spark, Flink, and Beam to create a full machine learning pipeline—including the annoying feature engineering and data prep components that we like to pretend don’t exist. Holden also explains why these feature prep stages need to be integrated into the serving layer. She concludes by examining changing industry trends, like Apache Arrow, and how they impact cross-language development for things like deep learning. Even if you’re not trying to raise a round of funding in Silicon Valley, this talk will give you tools to do interesting machine learning problems at scale.
Powerpoint realizado por la niña de 10 años Paula del Valle para explicar el trabajo del investigador Oriol Mitjà contra la enfermedad de pian a su clase del colegio Nuestra Señora de la Consolación (Benicarló).
Tempo August 2014
Cover Story: Skimboarding, Talent Watch,Beautiful Banaca
Check out our website: http://tempoplanet.com/
Check us out on our social media pages:
Facebook: https://www.facebook.com/pages/Abu-Dhabi-Tempo/114665148553019
Twitter: https://twitter.com/tempoplanet
Instagram: http://instagram.com/tempoplanet
Content Strategy Proposal for B2B Client Aparna Das
This is the final content strategy presentation for a Business consultancy firm. This is was a team project where we accomplished content audit, competitive-comparative analysis, defined brand voice spectrum, workflow recommendations, built website wireframe and an editorial calendar.
China's economy: slowing distorted and debt-addictedRBS Economics
China's economy is slowing. It's policy makers are having to contend with a massive debt-fuelled investment binge and the need to implement necessary reforms to rebalance the economy.
Senior Economist Marcus Wright goes behind the headlines with this stock take that sets out the main economic challenges facing China.
This is the presentation I used to teach the first class of Python SIG (Special Interest Group) which is a class for interested students taught by students. This is not meant to be used as standalone material, rather, it is meant to point you in a useful direction. If you are new to Python, and know another programming language, I hope this will be helpful to you.
Slides from the 30 minutes long version of "Wait, IPython can do that?!" presentation. I'm talking about some basic and advanced uses of IPython. For a a longer, 45 minutes long version of the slides, check: https://www.slideshare.net/SebastianWitowski/wait-ipython-can-do-that-154464752
Iterator - a powerful but underappreciated design patternNitin Bhide
Iterator design pattern is described in GoF ‘Design Patterns’ book. It is used at many places (e.g. Sql Cursor is a ‘iterator’), C++ standard template library uses iterators heavily. .Net Linq interfaces are based IEnumerable (i.e. iterator). However, I don’t see projects creating/using ‘custom’ iterator classes. Many problems can be solved ‘elegantly’ by use of customized iterators. This talk is about ‘power of iterators’ and how custom iterators can solve common problems and help create modular/reusable code components.
Key Discussion Points
Typical examples of iterators in common use.
Kind of problems that can be ‘elegantly’ solved with iterators
When to use custom iterators?
How write custom iterators in C++/C#
From webinar I did on TechGig
http://www.techgig.com/expert-speak/Iterator-a-powerful-but-underappreciated-pattern-449
Exploring Thermal Related Stuff in iDevices using Open-Source ToolKoan-Sin Tan
This is the era of so-called “dark silicon.” Thermal control is an important but seldom-talked topic. I could not find public information on how iOS does it. Recent checkm8 and follow-on checkra1n enable jailbreaking of iPhone 5s – iPhone X running iOS 12.3 and up. So that we can explore these devices with open-source tools
TensorFlow is the most popular machine learning framework nowadays. TensorFlow Lite (TFLite), open sourced in late 2017, is TensorFlow’s runtime designed for mobile devices, esp. Android cell phones. TFLite is getting more and more mature. One the most interesting new components introduced recently are its GPU delegate and new NNAPI delegate. The GPU delegate uses Open GL ES compute shader on Android platforms and Metal shade on iOS devices. The original NNAPI delegate is an all-or-nothing design (if one of the ops in the compute graph is not supported by NNAPI, the whole graph is not delegated). The new one is a per-op design. When an op in a graph is not supported by NNAPI, the op is automatically fell back to the CPU runtime. I’ll have a quick review TFLite and its interpreter, then walk the audience through example usage of the two delegates and important source code of them.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
A peek into Python's Metaclass and Bytecode from a Smalltalk User
1. A Peek into Python’s
Metaclass and Bytecode
as a Smalltalk User
Koan-Sin Tan
freedom_at_computer.org
COSCUP 2015, Taipei
2. why this topic
• ‘I was only vaguely aware of Smalltalk at the time; I remember being surprised
by its use of metaclasses (which is quite different from that in Python or
Ruby!) when I read about them much later. Smalltalk's bytecode was a bigger
influence of Python's bytecode though. I'd read about it in a book by Adele
Goldberg and others, I believe "Smalltalk-80: The Language and its
Implementation”’ [1]
• And, I had a talk comparing Ruby’s metaclass and byte code to Smalltalk’s in
the end of 2012 [2]
• google “smalltalk and ruby bytecode”
[1] http://python-history.blogspot.com/2013/10/origin-of-metaclasses-in-
python.html
[2] http://www.slideshare.net/kstan2/smalltalk-and-ruby-20121208-15542185
3. what won’t be discussed
• anything beyond simple metaclass and bytecode
comparisons
• So, no inline cache if you was in the SpiderMonkey talk
yesterday. Yes, I know inline cache was for Smalltalk-80. If
you want to know how inline cache is used in Smalltalk,
read an excellent article [1]
• And no other stuff in object model (whatever object model
means to you)
[1] http://www.mirandabanda.org/cogblog/2011/03/01/build-
me-a-jit-as-fast-as-you-can/
5. who am I
• Learnt to write program on MPF-II
• Used to be a programming language junkie
• Learnt a bit Smalltalk during early '90s, use it on
and off
• Recent interest in ST-80 because of Scratch and
BYOB/SNAP
• Knew little about Python
8. Scratch was written in Smalltalk
8
http://news.softpedia.com/images/reviews/large/
Scratch_Large_001.png
9. What I knew about python
• It’s a popular scripting language
• My classmate told me about Python in ’94 or ’95
• IPython notebook: using python and R to share
notes
• And of course, Python is more than Smalltalk-80
11. Quick Overview of ST-80
• Object-Oriented
Programming
• OO GUI environment,
IDE
• stack VM, bytecode
• Lambda, functional
language, block
• Message passing
• Design Pattern:
• if you read the GoF
book, you ran into
lots of Smalltalk
patterns before
• Learning/educational
• Logo and the dream
of Dynabook
13. Metaclass in ST-80
• From "purple book", Chap 16
1. Every class is ultimately a subclass of class Object, except for Object itself, which
has no superclass. In particular, Class is a subclass of ClassDescription, which is
a subclass of Behavior which is a subclass of Object
2. Every object is an instance of a class
3. Every class is an instance of a metaclass
4. All metaclasses are subclasses of Class
5. Every metaclass is an instance of Metaclass
6. The method of Class and it superclasses support the behavior common to all
objects that are classes
7. The methods of instances of Metaclass add the behavior specific to particular
classes
15. • 10 factorial class allSuperclasses --> an
OrderedCollection(Integer Number Magnitude
Object ProtoObject)
16. Python int
print(type(1))
<class 'int'>
print(type(1).__base__)
<class 'object'>
print(type(1).__base__.__base__)
None
print(type(1).__mro__)
(<class 'int'>, <class ‘object'>)
• So int, then object, no
hierarchy for numbers. How
about container types, e.g.,
set and dict? NO!
• Fortunately, there is another
path since python3000(?)
• There is PEP 3119 “Abstract Base
Classes” (ABC) and its companion
PEP 3141. So, there are ABCs for
numbers in module numbers and
collections module collections
numbers.Integral.__base__
<class 'numbers.Rational'>
numbers.Integral.__base__.__base__
<class 'numbers.Real'>
numbers.Integral.__base__.__base__.__base__
<class 'numbers.Complex'>
numbers.Integral.__base__.__base__.__base__.__base__
<class 'numbers.Number'>
numbers.Integral.__base__.__base__.__base__.__base__.__
base__
<class ‘object'>
numbers.Integral.__mro__
(<class 'numbers.Integral'>, <class
'numbers.Rational'>, <class 'numbers.Real'>, <class
'numbers.Complex'>, <class 'numbers.Number'>, <class
'object'>)
https://docs.python.org/3/reference/datamodel.html
Number
Complex
Real
Integral
10
Rational
object
Key
instance-of
17. a class named Metaclass
SmallInteger class --> SmallInteger class
Integer class --> Integer class
Number class --> Number class
Magnitude class --> Magnitude class
Object class --> Object class
ProtoObject class --> ProtoObject class
SmallInteger class superclass --> Integer class
Integer class superclass --> Number class
Number class superclass --> Magnitude class
Magnitude class superclass --> Object class
Object class superclass --> ProtoObject class
ProtoObject class superclass --> Class
Class class --> Class class
Class class class --> Metaclass
Metaclass class --> Metaclass class
Metaclass class class --> Metaclass
20. Class class class --> Metaclass
Metaclass superclass --> ClassDescription
ClassDescription superclass --> Behavior
Behavior superclass --> Object
Class class superclass --> ClassDescription class
ClassDescription class superclass --> Behavior class
Behavior class superclass --> Object class
20
21. Object
Magnitude
Number
Object class
Magnitude class
Number class
Key
instance-of
Integer class
SmallInteger
SmallInteger class
10
Integer
ProtoObject
ProtoObject class
Class
Class class
Metaclass
Metaclass class
ClassDescription
Behavior
ClassDescription class
Behavior class
21
24. Python metaclass
• LOAD_BUILD_CLASS:
LOAD_BUILD_CLASS¶
Pushes builtins.__build_class__() onto the
stack. It is later called by CALL_FUNCTION to
construct a class [1]
• builtins.__build_class__
static PyMethodDef builtin_methods[] = {
{"__build_class__", (PyCFunction)builtin___build_class__,
METH_VARARGS | METH_KEYWORDS, build_class_doc},
{"__import__", (PyCFunction)builtin___import__,
METH_VARARGS | METH_KEYWORDS, import_doc},
{"abs", builtin_abs, METH_O, abs_doc},
[1] https://docs.python.org/3/
library/dis.html
• builtin_build_class__
• if no specific metaclass was
given and there no special
metaclass in base classes of a
class, the default metaclass is
the ‘type’
• BTW, as far as I can tell there are
some classes have non-type
metaclasses in standard Python
distribution. We know numbers
and collections
• try “grep metaclass=“ in python
source code
25. builtin_build_class__()
static PyObject *
builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
{
…
if (meta == NULL) {
/* if there are no bases, use type: */
if (PyTuple_GET_SIZE(bases) == 0) {
meta = (PyObject *) (&PyType_Type);
}
/* else get the type of the first base */
else {
PyObject *base0 = PyTuple_GET_ITEM(bases, 0);
meta = (PyObject *) (base0->ob_type);
}
Py_INCREF(meta);
isclass = 1; /* meta is really a class */
}
…
}
29. Bytecode
• Bytecode is not new at all
• Smalltalk is one of early bytecode users
• Smalltalk bytecode
• end of Chapter 26, http://www.mirandabanda.org/
bluebook/
bluebook_chapter26.html#TheBytecodes26
• Chap. 28, http://www.mirandabanda.org/bluebook/
bluebook_chapter28.html
30. Smalltalk bytecode categories
• pushes
• indicates the source of an object to be added to the top of the
interpreter's stack
• stores
• indicates the variable whose value should be changed
• sends
• specifies the selector of a message to be sent and how many
arguments it should have.
• returns
• a value is returned for the message that invoked that
CompiledMethod
• and jumps
• you know what these are 30
31. Smalltalk bytecodes
Range Bits FuncHon
0-15 0000iiii Push Receiver Variable #iiii
16-31 0001iiii Push Temporary LocaHon #iiii
32-63 001iiiii Push Literal Constant #iiiii
64-95 010iiiii Push Literal Variable #iiiii
96-103 01100iii Pop and Store Receiver Variable #iii
104-111 01101iii Pop and Store Temporary LocaHon #iii
112-119 01110iii Push (receiver, true, false, nil, -1, 0, 1, 2) [iii]
120-123 011110ii Return (receiver, true, false, nil) [ii] From Message
124-125 0111110i Return Stack Top From (Message, Block) [i]
126-127 0111111i unused
128 10000000 jjkkkkkk Push (Receiver Variable, Temporary LocaHon, Literal Constant, Literal Variable) [jj] #kkkkkk
129 10000001 jjkkkkkk Store (Receiver Variable, Temporary LocaHon, Illegal, Literal Variable) [jj] #kkkkkk
130 10000010 jjkkkkkk Pop and Store (Receiver Variable, Temporary LocaHon, Illegal, Literal Variable) [jj] #kkkkkk
131 10000011 jjjkkkkk Send Literal Selector #kkkkk With jjj Arguments
132 10000100 jjjjjjjj kkkkkkkk Send Literal Selector #kkkkkkkk With jjjjjjjj Arguments
133 10000101 jjjkkkkk Send Literal Selector #kkkkk To Superclass With jjj Arguments
134 10000110 jjjjjjjj kkkkkkkk Send Literal Selector #kkkkkkkk To Superclass With jjjjjjjj Arguments
135 10000111 Pop Stack Top
136 10001000 Duplicate Stack Top
137 10001001 Push AcHve Context
138-143 unused
144-151 10010iii Jump iii + 1 (i.e., 1 through 8)
152-159 10011iii Pop and Jump 0n False iii +1 (i.e., 1 through 8)
160-167 10100iii jjjjjjjj Jump(iii - 4) *256+jjjjjjjj
168-171 101010ii jjjjjjjj Pop and Jump On True ii *256+jjjjjjjj
172-175 101011ii jjjjjjjj Pop and Jump On False ii *256+jjjjjjjj
176-191 1011iiii Send ArithmeHc Message #iiii
192-207 1100iiii Send Special Message #iiii
208-223 1101iiii Send Literal Selector #iiii With No Arguments
224-239 1110iiii Send Literal Selector #iiii With 1 Argument
240-255 1111iiii Send Literal Selector #iiii With 2 Arguments
31
32. • An example method,
forCompiledMethod
"to show how CompiledMethod works"
| foo |
foo := 'test'.
^ 1 + 2
• Bytecode: in System Browser of Squeak/Pharo, we can see bytecode easily
17 <20> pushConstant: 'test'
18 <68> popIntoTemp: 0
19 <76> pushConstant: 1
20 <77> pushConstant: 2
21 <B0> send: +
22 <7C> returnTop
32
40. observations
• ST-80’s bytecode is relatively simple or say
primitive one
• Python’s bytecode has many some unique
instructions and some specialized instructions for
builtin types (for legacy or performance reasons,
maybe)
• I know ST-80’s bytecode showed its age, but I am
surprised that Python’s bytecode is low level and
old too
41. So?
• We walked through metaclass and bytecode in
ST-80 and Python? Do you agree Guido’s words I
cited previously