Do you want the apocalypse, because this is how you get it

  • Post author:
  • Post category:Security

So I read this paper over the weekend. Naively, its a resonably interesting piece of research around using a generative AI to use descriptions of CVEs from their responsible disclosures to exploit unpatched systems autonomously. Now read that sentence again -- these people prompted Chat GPT4 with CVES which didn't have fixes yet, and had it hacking unpatched systems with an 85% success rate. We're doomed.

Continue ReadingDo you want the apocalypse, because this is how you get it

A gotcha with the Walrus operator

  • Post author:
  • Post category:Python

In New python syntax I was previously unaware of, I discussed some new operators I'd recently discovered. One of them is called the Walrus operator, which lets you write code like this: list = ['a', 'b', 'c'] def get_one(): if not list: return None return list.pop() while one := get_one(): print(one) See where we do the assignment inside the while? That code returns: c b a Which is as expected. However, the Walrus operator is strict about needing a None returned to end the iteration. I had code which was more like this: list = [('a', 1), ('b', 2), ('c', 3)] def get_one(): if not list: return None, None return list.pop() while one := get_one(): print(one) And the while loop never terminates. It just prints (None, None) over and over. So there you go.

Continue ReadingA gotcha with the Walrus operator

Debugging

  • Post author:
  • Post category:Book

One of the other architects at work was running a reading group for our North American comrades, and I felt left out so I figured I may as well just pick up the book to see what the deal was. This book is a bit old, and was written at the time to try and be funny, but to be honest I don't think the humour has aged well and it makes the book jarring to read. Overall I'd describe the book as having been written in the style of a long form chatty blog post, which is a bit unusual. 90% of the readers of this book will be looking for advice on how to debug software systems, but the book frequently uses hardwaare systems as examples. That speaks to the author's background, but its not super helpful for modern audiences living in a software defined world. The book is also a bit dated in terms of terminology and expectations of the work environment -- for example, the discussion of repeatable testing doesn't mention automated regression testing at all, and the only mention of automated tests is fleeting at best. Another example is that the author recommends that you…

Continue ReadingDebugging

New python syntax I was previously unaware of

  • Post author:
  • Post category:Python

This post documents the new syntax features I learned about while reading cpython internals. You can create more than one context manager on a single line. So for example Shaken Fist contains code like this: with open(path + '.new', 'w') as o: with open(path, 'r') as i: ... That can now be written like this: with open(path + '.new', 'w') as o, open(path, 'r') as i: ...   You can assign values in a while statement, but only one. Instead of this: d = f.read(8000) while f: ... d = f.read(8000) You can write this: while d := f.read(8000): ... But unfortunately this doesn't work: while a, b := thing(): ...   You can use underscores as commands in long numbers to make them easier to read. For example, you can write 1000000 or 1_000_000 and they both mean the same thing.   You can refer to positional arguments by name, but you can also disable that. I didn't realise that this was valid python: def foo(bar=None): print(bar) foo(bar='banana') You can turn it off with a forward slash in the argument list though, which should separate positional arguments from named arguments: def foo(bar, /, extra=None): print(bar) print(extra) foo('banana', extra='frog') The above example…

Continue ReadingNew python syntax I was previously unaware of

cpython internals

  • Post author:
  • Post category:BookPython

I have been paid money to write Python code since about 2006, so I figured it was probably time that I should understand some of the inner workings of Python. I therefore picked up two books on the topic, this one being the first of the two.

This book to be honest isn’t completely what I expected. Its very well written and quite interesting, but its more about the things you’d need to know to become a Python core developer, rather than the things you should know as a user of Python like how the Python dictionary implementation is built.

(If you want that specifically, this video is an excellent introduction).

(more…)

CPython Internals Book Cover CPython Internals
Anthony Shaw
May 5, 2021
396

Get your guided tour through the Python 3.9 interpreter: Unlock the inner workings of the Python language, compile the Python interpreter from source code, and participate in the development of CPython. Are there certain parts of Python that just seem like magic? This book explains the concepts, ideas, and technicalities of the Python interpreter in an approachable and hands-on fashion. Once you see how Python works at the interpreter level, you can optimize your applications and fully leverage the power of Python.

Continue Readingcpython internals

Shift

  • Post author:
  • Post category:Book

This is the second book in the Silo series, following on the Wool, which I recently read. I think to a certain extend this book is better than the first one -- I certainly found it compelling. An excellent read that explains how the universe described in Wool came to be, but yet also sets the scene for the third book in the trilogy.

Continue ReadingShift

Solve for Happy

  • Post author:
  • Post category:Book

Mo Gawdat was kind of a big deal, at IBM, Microsoft, and then Google. But he was unhappy, so he decided to take an engineering approach and try to systematically “solve for happy” and work out why adding more money, shiny objects, and adoration of others didn’t actually make him happy.

(more…)

Solve for Happy Book Cover Solve for Happy
Mo Gawdat
January 10, 2019
368

Solve for Happy is a startlingly original book about creating and maintaining happiness, written by a top Google executive with an engineer's training and fondness for thoroughly analyzing a problem.

Continue ReadingSolve for Happy

Starter Villain

  • Post author:
  • Post category:Book

Now, I might be biased because I like John Scalzi's stuff, but this book was really good. It starts slower than a normal Scalzi book, and takes a couple of chapters to really get going, but I am glad I was patient with it. Apart from that its a quick easy read. Its a typical Scalzi book, light hearted and fun. I think this one requires you suspend disbelief a little harder than others (except perhaps for Redshirts) but that doesn't make it less enjoyable.

Continue ReadingStarter Villain

Wool

  • Post author:
  • Post category:Book

Chet bought me this book and demanded I read it, and honestly that was a good call. The book reminds me a bit of  Oryx and Crake, but perhaps that's unfair given I read that one eight years ago and have probably forgotten some important details. The book is well paced and engaging. Despite being as long as many of Neil Stephenson's books, I felt it was a much more approachable read than that. I found the second half of the book a bit harder to read that the first half, because it doesn't pull many punches in terms of the consequences of people's actions and is pretty good at building suspense. There were definitely points where I had to pause because I was pretty sure something bad was going to happen to someone I'd grown fond of. That said, it was still a great read. I've gone and bought the next two in the series because I'm confident I'm going to want to read them now too.

Continue ReadingWool

Understanding Compression

  • Post author:
  • Post category:Book

I bought this book on a whim, because I was trying to understand a compression scheme and had trouble finding good documentation on it. The book overall is written in a quite conversational style that I find a bit distracting from the content, and the introduction is a bit repetitive -- yes I get it, there's some maths involved. Thanks. That said, the content is a solid and quite approchable introduction to the topic area. I haven't ever thought before about entropy in information theory for example, I now feel like I could give a coherent elevator description of the topic. Another example is the description of Huffman codes. Here the topic is introduced with four pages and a few diagrams and I "get it". In the random algorithms book on my shelf (Introduction to Algorithms, third edition by Cormen, Leiserson, Rivest, and Stein), the same content takes ten pages and includes a six page set of lemmas around the code's correctness. Both descriptions would get you there in the end, but Understanding Compression's description is definitely more approachable. Overall, its very rare for me to sit down and actually read a technical book from cover to cover, but this book…

Continue ReadingUnderstanding Compression

End of content

No more pages to load