We are currently in the process of converting the website to the new design. Some pages, like this one, are still broken. We appreciate your patience.
Bitwise»Episode Guide
Domain-Specific Languages In Python, Part 3
?
?

Keyboard Navigation

Global Keys

[, < / ], > Jump to previous / next episode
W, K, P / S, J, N Jump to previous / next marker
t / T Toggle theatre / SUPERtheatre mode
V Revert filter to original state Y Select link (requires manual Ctrl-c)

Menu toggling

q Quotes r References f Filter y Link c Credits

In-Menu Movement

a
w
s
d
h j k l


Quotes and References Menus

Enter Jump to timecode

Quotes, References and Credits Menus

o Open URL (in new tab)

Filter Menu

x, Space Toggle category and focus next
X, ShiftSpace Toggle category and focus previous
v Invert topics / media as per focus

Filter and Link Menus

z Toggle filter / linking mode

Credits Menu

Enter Open URL (in new tab)
0:09Recap and set the stage for the day
🗩
0:09Recap and set the stage for the day
🗩
0:09Recap and set the stage for the day
🗩
1:46Review the bit-oriented nature of our DSL (domain-specific language) rattle, and its lack of abstraction facilities
📖
1:46Review the bit-oriented nature of our DSL (domain-specific language) rattle, and its lack of abstraction facilities
📖
1:46Review the bit-oriented nature of our DSL (domain-specific language) rattle, and its lack of abstraction facilities
📖
6:18A few words on the simulation speed advantage from keeping things as bit-vectors
🗩
6:18A few words on the simulation speed advantage from keeping things as bit-vectors
🗩
6:18A few words on the simulation speed advantage from keeping things as bit-vectors
🗩
8:00Consider allowing a circuit component connection-oriented way of expressing things, in addition to the language's current expression-oriented way
🗩
8:00Consider allowing a circuit component connection-oriented way of expressing things, in addition to the language's current expression-oriented way
🗩
8:00Consider allowing a circuit component connection-oriented way of expressing things, in addition to the language's current expression-oriented way
🗩
9:38Consider supporting "module", in Verilog parlance
🗩
9:38Consider supporting "module", in Verilog parlance
🗩
9:38Consider supporting "module", in Verilog parlance
🗩
11:35An example @module
🗩
11:35An example @module
🗩
11:35An example @module
🗩
17:34An example nested @module
🗩
17:34An example nested @module
🗩
17:34An example nested @module
🗩
25:00Note the addition of ordered dictionaries in Python 3.6
🗩
25:00Note the addition of ordered dictionaries in Python 3.6
🗩
25:00Note the addition of ordered dictionaries in Python 3.6
🗩
29:52Set up to implement modules
🗩
29:52Set up to implement modules
🗩
29:52Set up to implement modules
🗩
32:15Dive into implementing modules, starting by introducing Bit and BitVector classes, and memo() to memoise the result of bits()
32:15Dive into implementing modules, starting by introducing Bit and BitVector classes, and memo() to memoise the result of bits()
32:15Dive into implementing modules, starting by introducing Bit and BitVector classes, and memo() to memoise the result of bits()
36:08Demo the utility of @memo
🗩
36:08Demo the utility of @memo
🗩
36:08Demo the utility of @memo
🗩
37:30Establish the syntax bit[8] which comes out equal to bits(8) due to memoisation
37:30Establish the syntax bit[8] which comes out equal to bits(8) due to memoisation
37:30Establish the syntax bit[8] which comes out equal to bits(8) due to memoisation
39:20Define __and__() in the Node class, introducing check_same_type()
39:20Define __and__() in the Node class, introducing check_same_type()
39:20Define __and__() in the Node class, introducing check_same_type()
42:32Introduce BinaryNode class
42:32Introduce BinaryNode class
42:32Introduce BinaryNode class
43:55Introduce as_node() and ConstantNode class
43:55Introduce as_node() and ConstantNode class
43:55Introduce as_node() and ConstantNode class
48:41Introduce cast() in the Bit and BitVector classes, and __repr__() in Bit, BitVector and ConstantNode
48:41Introduce cast() in the Bit and BitVector classes, and __repr__() in Bit, BitVector and ConstantNode
48:41Introduce cast() in the Bit and BitVector classes, and __repr__() in Bit, BitVector and ConstantNode
52:31Test as_node()
🏃
52:31Test as_node()
🏃
52:31Test as_node()
🏃
54:34Define __rand__() in Node, and introduce InputNode class
54:34Define __rand__() in Node, and introduce InputNode class
54:34Define __rand__() in Node, and introduce InputNode class
55:53Demo usage of an InputNode, and a trick for doing embedded DSL in Python
🗩
55:53Demo usage of an InputNode, and a trick for doing embedded DSL in Python
🗩
55:53Demo usage of an InputNode, and a trick for doing embedded DSL in Python
🗩
57:21Introduce input()
57:21Introduce input()
57:21Introduce input()
57:57Introduce Module class, using Python's new __init_subclass__
57:57Introduce Module class, using Python's new __init_subclass__
57:57Introduce Module class, using Python's new __init_subclass__
59:00Introduce Adder class using Module class, and walk us through what happens when Python executes this1
59:00Introduce Adder class using Module class, and walk us through what happens when Python executes this1
59:00Introduce Adder class using Module class, and walk us through what happens when Python executes this1
1:00:49Change Adder and Module to use a metaclass, also defining __repr__ in the InputNode class
1:00:49Change Adder and Module to use a metaclass, also defining __repr__ in the InputNode class
1:00:49Change Adder and Module to use a metaclass, also defining __repr__ in the InputNode class
1:06:28Demo the utility of this Module metaclass, noting the alternative way of doing this with a decorator
🏃
1:06:28Demo the utility of this Module metaclass, noting the alternative way of doing this with a decorator
🏃
1:06:28Demo the utility of this Module metaclass, noting the alternative way of doing this with a decorator
🏃
1:07:11Introduce module() to be used as a decorator
1:07:11Introduce module() to be used as a decorator
1:07:11Introduce module() to be used as a decorator
1:09:09Demo this decorator-based solution, remove Module class, and walk through how decorators work
🏃
🖮
1:09:09Demo this decorator-based solution, remove Module class, and walk through how decorators work
🏃
🖮
1:09:09Demo this decorator-based solution, remove Module class, and walk through how decorators work
🏃
🖮
1:11:16Add an optional name to the Node class
1:11:16Add an optional name to the Node class
1:11:16Add an optional name to the Node class
1:13:11Suppress the types in our expression representation
1:13:11Suppress the types in our expression representation
1:13:11Suppress the types in our expression representation
1:13:42Run it to see the expressions in our Adder class
🏃
1:13:42Run it to see the expressions in our Adder class
🏃
1:13:42Run it to see the expressions in our Adder class
🏃
1:14:20Review module() and consider the need to create module instance nodes
📖
1:14:20Review module() and consider the need to create module instance nodes
📖
1:14:20Review module() and consider the need to create module instance nodes
📖
1:15:23Introduce Module class, OutputNode class and output(), and enable module() to fill out _inputs and _outputs
1:15:23Introduce Module class, OutputNode class and output(), and enable module() to fill out _inputs and _outputs
1:15:23Introduce Module class, OutputNode class and output(), and enable module() to fill out _inputs and _outputs
1:18:48Test the module inputs and outputs
🏃
1:18:48Test the module inputs and outputs
🏃
1:18:48Test the module inputs and outputs
🏃
1:20:20Introduce the notion of _connections in the Module class
1:20:20Introduce the notion of _connections in the Module class
1:20:20Introduce the notion of _connections in the Module class
1:25:35Run it to see the output
🏃
1:25:35Run it to see the output
🏃
1:25:35Run it to see the output
🏃
1:25:42Implement our Adder8 and Adder16 modules sketched out earlier
1:25:42Implement our Adder8 and Adder16 modules sketched out earlier
1:25:42Implement our Adder8 and Adder16 modules sketched out earlier
1:27:54Run it to see the inputs and outputs of our modules
🏃
1:27:54Run it to see the inputs and outputs of our modules
🏃
1:27:54Run it to see the inputs and outputs of our modules
🏃
1:28:20Enable __init__() in the Module class to check_same_type()
1:28:20Enable __init__() in the Module class to check_same_type()
1:28:20Enable __init__() in the Module class to check_same_type()
1:30:25Test plugging a 16-bit node into an 8-bit input and hit a TypeError as expected
🏃
1:30:25Test plugging a 16-bit node into an 8-bit input and hit a TypeError as expected
🏃
1:30:25Test plugging a 16-bit node into an 8-bit input and hit a TypeError as expected
🏃
1:30:41Break
🗹
1:30:41Break
🗹
1:30:41Break
🗹
1:31:54Return
🗹
1:31:54Return
🗹
1:31:54Return
🗹
1:32:12Implement type checking, adding __getitem__() to the Node class, and introducing IndexNode class
1:32:12Implement type checking, adding __getitem__() to the Node class, and introducing IndexNode class
1:32:12Implement type checking, adding __getitem__() to the Node class, and introducing IndexNode class
1:39:50Print Adder8._nodes
🏃
1:39:50Print Adder8._nodes
🏃
1:39:50Print Adder8._nodes
🏃
1:40:22Test the type checking, fixing IndexNode to correctly detect out of bounds indices
🏃
🖮
1:40:22Test the type checking, fixing IndexNode to correctly detect out of bounds indices
🏃
🖮
1:40:22Test the type checking, fixing IndexNode to correctly detect out of bounds indices
🏃
🖮
1:41:02Implement bit slicing, introducing SliceNode class
1:41:02Implement bit slicing, introducing SliceNode class
1:41:02Implement bit slicing, introducing SliceNode class
1:47:57Test the bit slicing
🏃
1:47:57Test the bit slicing
🏃
1:47:57Test the bit slicing
🏃
1:48:40Compose error message for check_same_type()
1:48:40Compose error message for check_same_type()
1:48:40Compose error message for check_same_type()
1:48:59Trigger that out-of-bounds error and continue to test the bit slicing
🏃
1:48:59Trigger that out-of-bounds error and continue to test the bit slicing
🏃
1:48:59Trigger that out-of-bounds error and continue to test the bit slicing
🏃
1:49:33Test partial connections, noting that it's picking up the template rather than the instance version of the node
🏃
1:49:33Test partial connections, noting that it's picking up the template rather than the instance version of the node
🏃
1:49:33Test partial connections, noting that it's picking up the template rather than the instance version of the node
🏃
1:51:37Make module() delete its own template version of the nodes, and __init__() in the Module class to fill in the real instance nodes, introducing ModuleInputNode class
1:51:37Make module() delete its own template version of the nodes, and __init__() in the Module class to fill in the real instance nodes, introducing ModuleInputNode class
1:51:37Make module() delete its own template version of the nodes, and __init__() in the Module class to fill in the real instance nodes, introducing ModuleInputNode class
1:59:39Run it to see our partial connection
🏃
1:59:39Run it to see our partial connection
🏃
1:59:39Run it to see our partial connection
🏃
2:00:46Enable module() to handle partial connections for Modules, renaming "nodes" to "definitions"
2:00:46Enable module() to handle partial connections for Modules, renaming "nodes" to "definitions"
2:00:46Enable module() to handle partial connections for Modules, renaming "nodes" to "definitions"
2:05:17Run it to see some uninitialised data
🏃
2:05:17Run it to see some uninitialised data
🏃
2:05:17Run it to see some uninitialised data
🏃
2:05:41Define __repr__() in the Module class
2:05:41Define __repr__() in the Module class
2:05:41Define __repr__() in the Module class
2:07:49Run it to see our Adder8 module all correctly printed out
🏃
2:07:49Run it to see our Adder8 module all correctly printed out
🏃
2:07:49Run it to see our Adder8 module all correctly printed out
🏃
2:09:08Summarise the day's work on syntactic sugar, type checking and modules
🗩
2:09:08Summarise the day's work on syntactic sugar, type checking and modules
🗩
2:09:08Summarise the day's work on syntactic sugar, type checking and modules
🗩
2:09:45That's enough for today, with a glimpse into the future on additional semantic checking
🗩
2:09:45That's enough for today, with a glimpse into the future on additional semantic checking
🗩
2:09:45That's enough for today, with a glimpse into the future on additional semantic checking
🗩