This week in KDE: Panel Intellihide and Wayland Presentation Time

Planet KDE - Sat, 2023-11-18 01:14

It’s great to see lots of people running the Plasma 6 Alpha release, which has resulted in a spike of bug reports, as we had hoped and expected. So keep at it! Focus is already shifting to bug fixing now that most planned features are merged, with only a few to go. So far I’ve been following a policy of only noting fixes for bugs that affect shipping software, but I might have to change that given the loooong bugfixing window for Plasma 6. Still chewing on it.

Anyway, lots to talk about this week!

Plasma 6

(Includes all software to be released on the February 28th mega-release: Plasma 6, Frameworks 6, and apps from Gear 24.02)

General infoOpen issues: 144

Plasma Panels have now gained a new visibility mode: “Dodge Windows” aka “intelligent auto-hide!” In essence, the Panel auto-hides when touched by a window, but is otherwise visible (Bharadwaj Raju and Niccolò Venerandi, link)

KWin now implements support for the Wayland “Presentation time” protocol! (Xaver Hugl, link)

Carl Schwan has been improving the look and feel of QtWidgets-based KDE apps left and right, and they just look gorgeous now! (Carl Schwan, link 1, link 2, link 3, link 4, link 5, link 6, link 7, link 8, and link 9):

List items throughout QML-based KDE software now use a nicer rounded highlight style (Arjen Hiemstra and Carl Schwan, link):

When you create a new blank panel, it now comes with an “Add Widgets…” button on it to save you some time, because let’s face it, the next thing you were about to do was add some widgets! (Niccolò Venerandi, link)

The Breeze icon theme has gained symbolic variants of the weather icons, which means that when you use a Weather Report widget on your panel, it’s no longer the only thing in or near the System tray with a colorful icon (Alois Spitzbart, link):

When you scroll down in one of the “Get new [thing]” dialogs to load new content, it now loads without throwing up a giant full-window loading indicator that blocks the view of what you were looking at (Rishi Kumar, link)

Ported all of Plasma’s widget configuration dialogs to use the same base components we use for system Settings pages, allowing for more unified code and also frameless, edge-to-edge scrollable views like in System Settings (Nicolas Fella, link)

the Task Manager widget’s rather confusing “Always arrange tasks in columns of as many rows” setting has been re-done in the UI to be comprehensible (Niccolò Venerandi, link):

Improved app launch time in the Plasma Wayland session (David Edmundson, link)

Elisa now always uses its internal music indexer rather than Baloo. This unifies the UX and indexing codepaths, as many users did not have Baloo available and were using the internal indexer anyway. The result is 10 open bug reports fixed! (Christoph Cullmann, link)

Konsole’s default “Breeze” terminal color scheme now uses the more attention-getting and attractive “Plasma Blue” color for intense text (Thiago Sueto, link):

In Dolphin, you can now toggle inline previews on and off with the F12 key, just like how you can in the open/save dialogs (Eric Armbruster, link)

Other Significant Bugfixes

(This is a curated list of e.g. HI and VHI priority bugs, Wayland showstoppers, major regressions, etc.)

Brightness control now works on FreeBSD systems (Gleb Popov, Plasma 5.27.10. Link)

Your preferred web browser is now looked up more reliably (Harald Sitter, Plasma 5.27.10. Link)

Moving the pointer over a partially-visible list item in various Plasma widgets no longer auto-scrolls the view to make that list item totally visible, which could be rather disruptive in certain circumstances (e.g. for very large list items, or when moving the pointer up from the bottom of the list to try to reach an item at the top) and annoyed a lot of people (Bharadwaj Raju, Plasma 6.0. Link)

Dolphin’s ISO integration tools now work again after briefly breaking (Eric Armbruster, Dolphin 23.08.3. Link)

Other bug-related information of interest:

…And Everything Else

This blog only covers the tip of the iceberg! If you’re hungry for more, check out https://planet.kde.org, where you can find more news from other KDE contributors.

How You Can Help

We’re hosting our Plasma 6 fundraiser right now and need your help! Thanks to you we’ve hit the 70% mark, which is amazing! To be honest, I had thought the goal of 500 members was too ambitious, but you folks have proven me wrong so far. But nonetheless, while 70% is amazing, 70% is not 100%, so if you like the work we’re doing, spreading the wealth by becoming a member is a great way to share the love.

If you’re a developer, work on Qt6/KF6/Plasma 6 issues! Which issues? These issues. Plasma 6 is usable for daily driving now, but still in need of bug-fixing and polishing to get it into a releasable state by February.

Otherwise, visit https://community.kde.org/Get_Involved to discover other ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!

Categories: FLOSS Project Planets

John Cook: Factored random numbers

Planet Python - Fri, 2023-11-17 20:42

A couple days ago Michael Nielsen posted an image of a one-page paper that gives an algorithm for generating factored random numbers, uniformly distributed from 1 to some designated N.

The algorithm does not generate random numbers then factor them. It’s more efficient than that, generating the factorization along with the final result. It does require testing for whether a number is prime, but this is more efficient than factorization.

I thought about trying to code up the algorithm in Python, but then I see that @iconjack beat me to it.

from sympy import isprime from random import random, randint def randfacts(N): while True: n, r, s = N, 1, [] while n > 1: if r > N: break if isprime(n := randint(1,n)): r *= n s.append(n) else: if random() r/N: return r, s The post Factored random numbers first appeared on John D. Cook.
Categories: FLOSS Project Planets

Pythonicity: Composition vs. inheritance

Planet Python - Fri, 2023-11-17 19:00
Contrarian view on composition over inheritance.

The conventional wisdom is to prefer composition over inheritance. More specifically to use delegation over single inheritance.

Like the recommendation on closing files, the advice is well-intentioned but omits the fact that Python does not support it well. Python has no mechanism for embedding or forwarding methods. And the despite its famous duck-typing, there are many cases where a type must be subclassed to be substitutable (particularly if implemented in CPython).

The below example comes from a popular PyCon talk called Beyond PEP 8. The goal is adapt a Java-esque interface into pythonic code.

Original implementation import jnettool.tools.elements.NetworkElement import jnettool.tools.Routing import jnettool.tools.RouteInsector ne = jnettool.tools.elements.NetworkElement('') try: routing_table = ne.getRoutingTable() except jnettool.tools.elements.MissingVar: logging.exception('No routing table found') ne.cleanup('rollback') else: num_routes = routing_table.getSize() for RToffset in range(num_routes): route = routing_table.getRouteByIndex(RToffset) name = route.getName() ipaddr = route.getIPAddr() print "%15s -> %s" % (name, ipaddr) finally: ne.cleanup('commit') ne.disconnect() Proposed interface from nettools import NetworkElement with NetworkElement('') as ne: for route in ne.routing_table: print "%15s -> %s" % (route.name, route.ipaddr) Proposed solution import jnetool.tools.elements.NetworkElement import jnetool.tools.Routing class NetworkElementError(Exception): pass class NetworkElement(object): def __init__(self, ipaddr): self.ipaddr = ipaddr self.oldne = jnetool.tools.elements.NetworkElement(ipaddr) @property def routing_table(self): try: return RoutingTable(self.oldne.getRoutingTable()) except jnetool.tools.elements.MissingVar: raise NetworkElementError('No routing table found') def __enter__(self): return self def __exit__(self, exctype, excinst, exctb): if exctype == NetworkElementError: logging.exception('No routing table found') self.oldne.cleanup('rollback') else: self.oldne.cleanup('commit') self.oldne.disconnect() def __repr__(self): return '%s(%r)' % (self.__class__.__name__, self.ipaddr) class RoutingTable(object): def __init__(self, oldrt): self.oldrt = oldrt def __len__(self): return self.oldrt.getSize() def __getitem__(self, index): if index >= len(self): raise IndexError return Route(self.oldrt.getRouteByIndex(index)) class Route(object): def __init__(self, old_route): self.old_route = old_route @property def name(self): return self.old_route.getName() @property def ipaddr(self): return self.old_route.getIPAddr()

No dispute that the interface is superior, but the implementation is using delegation as if it is dogma. The usage pattern has to be extrapolated from one example, but here are the issues:

  • Custom exceptions are not helpful if they do nothing. The consumer of this code does not use NetworkElementError, and has lost the traceback if it did. Error hiding is not error handling.
  • Comparing classes with == is widely considered an anti-pattern, as opposed to is or issubclass.
  • The Route object doesn’t need to delegate. There is no reason to assume that the underlying attribute access must be lazy, particularly since the iteration could be lazy instead. A named tuple or dataclass would suffice here.
  • The RoutingTable object doesn’t need to delegate. There is no need to support random access or lazy evaluation. Its only addition to the interface is to be sequence-like, which could be trivially accomplished by a sequence.
  • The NetworkElement doesn’t need to delegate. It has the same name, same constructor, a repr designed to appear as the original, and only extends behavior. If this doesn’t pass as an is-a relation, nothing does.
Simple solution import collections from jnettool.tools import elements Route = collections.namedtuple('Route', ['name', 'ipaddr']) class NetworkElement(elements.NetworkElement): @property def routing_table(self): table = self.getRoutingTable() routes = map(table.getRouteByIndex, range(table.getSize())) return [Route(route.getName(), route.getIPAddr()) for route in routes] def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): if isinstance(exc_val, elements.MissingVar): logging.exception("No routing table found") self.cleanup('rollback') else: self.cleanup('commit') self.disconnect()

Which version is more maintainable? Surely the simpler one.

Which version is more extensible? Well, by whom? The implementor can extend either just as easily. The caller can use the inherited version without losing any functionality.

So a better question might be which version is more flexible or reusable? Surely the inherited version, because the delegated version would need to access oldne. Even naming the delegate is a pain point, because one has to decide if it is a part of the public interface or not. Should it have 0, 1, or 2 leading underscores? Delegation is often touted as achieving both encapsulation and extensibility, despite being opposing goals.

Finally, there is also a simpler interface, again with the caveat that there is only one usage example. An iterable of 2-field objects, one of which is called name, and “points to” the other field. Sounds like a mapping.

class NetworkElement(elements.NetworkElement): @property def routing_table(self): table = self.getRoutingTable() routes = map(table.getRouteByIndex, range(table.getSize())) return {route.getName(): route.getIPAddr() for route in routes} ...
Categories: FLOSS Project Planets

Jonathan Dowland: HLedger, regex matches and field assignments

Planet Debian - Fri, 2023-11-17 16:39

I've finally landed a patch/feature for HLedger I've been working on-and-off (mostly off) since around March.

HLedger has a powerful CSV importer which you configure with a set of rules. Rules consist of conditional matchers (does field X in this CSV row match this regular expression?) and field assignments (set the resulting transaction's account to Y).

motivating problem 1

Here's an example of one of my rules for handling credit card repayments. This rule is applied when I import a CSV for my current account, which pays the credit card:

if AMERICAN EXPRESS account2 liabilities:amex

This results in a ledger entry like the following

2023-10-31 AMERICAN EXPRESS assets:current £- 6.66 liabilities:amex £ 6.66

My current account statements cover calendar months. My credit card period spans mid-month to mid-month. I pay it off by direct debit, which comes out after the credit card period, towards the very end of the calendar month. That transaction falls roughly halfway through the next credit card period.

On my credit card statements, that repayment is "warped" to the start of the list of transactions, clearing the outstanding balance from the previous period.

When I import my credit card data to HLedger, I want to compare the result against a PDF statement to make sure my ledger matches reality. The repayment "warping" makes this awkward, because it means the balance for roughly half the new transactions (those that fall before the real-date of the repayment) don't match up.

motivating problem 2

I start new ledger files each year. I need to import the closing balances from the previous year to the next, which I do by exporting the final balance from the previous year in CSV and importing that into the new ledgers in the usual way.

Between 2022 and 2023 I changed the scheme I use for account names so I need to translate between the old and the new in the opening balances. I couldn't think of a way of achieving this in the import rules (besides writing a bespoke rule for every possible old account name) so I abused another HLedger feature instead, HLedger aliases. For example I added this alias in my family ledger file for 2023

alias /^family:(.*)/ = \1

These are ugly and I'd prefer to get rid of them.

regex match groups

A common feature of regular expressions is defining match groups which can be referenced elsewhere, such as on the far-side of a substitution. I added match group support to HLedger's field assignments.

addressing date warping

Here's an updated version rule from the first motivating problem:

if AMERICAN EXPRESS & %date (..)/(..)/(....) account2 liabilities:amex comment2 date:\3-\2-16

We now match on on extra date field, and surround the day/month/year components with parentheses to define match groups. We add a second field assignment too, setting the second posting's "comment" field to a string which, once the match groups are interpolated, instructs HLedger to do date warping (I wrote about this in date warping in HLedger)

The new transaction looks like this:

2023-10-31 AMERICAN EXPRESS assets:current £- 6.66 liabilities:amex £ 6.66 ; date:2023-10-16 getting rid of aliases

In the second problem, I can strip off the unwanted account name prefixes at CSV import time, with rules like this

if %account2 ^family:(.*)$ account2 \1 When!

This stuff landed a week ago in early November, and is not yet in a Hledger release.

Categories: FLOSS Project Planets

mark.ie: How to use once() in Drupal

Planet Drupal - Fri, 2023-11-17 10:19

Once is a Drupal library - available on npm - that ensures your JavaScript only runs once when working on any item.

Categories: FLOSS Project Planets

Jonathan Dowland: denver luna

Planet Debian - Fri, 2023-11-17 08:59

I haven't done one of these in a while!

Denver Luna is the latest single from Underworld, here on a pink 12" vinyl. The notable thing about this release was it was preceded by an "acapella" mix, consisting of just Karl Hyde's vocals: albeit treated and layered. Personally I prefer the "main" single mix, which calls back to their biggest hits. The vinyl also features an instrumental take, which is currently unavailable in any other formats.

The previous single (presumably both from a forthcoming album) was and the colour red.

In this crazy world we live in, this was limited to 1,000 copies. Flippers have sold 4 on eBay already, at between £ 55 and £ 75.

Categories: FLOSS Project Planets

Mike Driscoll: Episode 22 – Git and Django with Adam Johnson

Planet Python - Fri, 2023-11-17 08:57

You may know Adam from all his work around the Django web framework. If you head to the Python Package Index (PyPI), you will see that Adam has made or contributed to more than 80 projects!

Adam recently released a new book called Boost Your Git DX

Listen in as we chat about:

  • Book writing
  • Django
  • Python
  • Git
  • and much more!

The post Episode 22 – Git and Django with Adam Johnson appeared first on Mouse Vs Python.

Categories: FLOSS Project Planets

Web Review, Week 2023-46

Planet KDE - Fri, 2023-11-17 08:28

Let’s go for my web review for the week 2023-46.

Blender 4.0

Tags: tech, blender, 3d

Yet another very impressive release for Blender. This is really one of the best in its class.


The French National Police is unlawfully using an Israeli facial recognition software

Tags: tech, france, surveillance

Welcome in France, a country scared of its own population where the police uses facial recognition illegally. But don’t worry, we can expect attempts to make it legal in the coming months or years instead of addressing the problem. Will it make it less shameful? I don’t think so.


No Bing, no Edge, no upselling: De-crufted Windows 11 coming to Europe soon | Ars Technica

Tags: tech, politics, law

This is going to be interesting to see how this new regulation unfolds. Its impacts are well beyond just Microsoft.


Moving our Encrypted DNS servers to run in RAM | Mullvad VPN

Tags: tech, dns, privacy

Excellent, looks like a public DNS server worth using.


The Use Cases and Benefits of SVCB and HTTPS DNS Record Types

Tags: tech, dns

Now that they’re standardized better learn about those new record types.


RFC 9420 – A Messaging Layer Security Overview

Tags: tech, protocols, standard, security

Finally a standardized protocol for end-to-end encryption! Let’s see where this gets used.


Don’t Build AI Products The Way Everyone Else Is Doing It

Tags: tech, ai, machine-learning, design, architecture

A balanced view, that’s refreshing. Indeed we see too many “let’s call the OpenAI APIs and magic will happen”. This is very short sighted, much better can be done.


We are drowning in Google’s magnanimity - kpassa.me

Tags: tech, google, infrastructure

Half a rant but interesting… Why are people making popular solutions to problems they’ll never have? Just because it’s been released by Google?


We Need to Bring Back Webrings

Tags: tech, blog

I admit I miss webrings indeed. They were great to discover new blogs with nice content.


Upgrade your Development Environments with Devbox | Alan Norbauer

Tags: tech, tools, developer-experience

Definitely looks interesting. Might be a good way to uniformize developer environment management across projects.


Why Rust in Production? | Corrode Rust Consulting

Tags: tech, rust

This is a well balanced view on the Rust ecosystem as of today. It highlights fairly well where it shines (safety, predictability, bugs found early) but it also mentions the current issues linked to its maturity.


fx – command-line tool for JSON

Tags: tech, tools, command-line, json

Looks like a very good tool for handling JSON files. Might come in handy next to jq… maybe it’ll replace jless.


Navigating around in your shell

Tags: tech, command-line, tools

Good list of tips and aliases. Might inspire a few changes in your setup.


How git cherry-pick and revert use 3-way merge

Tags: tech, tools, git

Ever wondered how git implements cherry-pick and revert? Here are a good way to understand them. Also explains what is the 3-way merge git uses widely.


Laurence Tratt: Four Kinds of Optimisation

Tags: tech, optimization

Not in full agreement with this, but having a rough idea of the different leverages you can use for optimizations is worthwhile.


67 Weird Debugging Tricks Your Browser Doesn’t Want You to Know | Alan Norbauer

Tags: tech, debugging, web, browser

A few interesting tricks in there, the web platform definitely helps in term of tooling.


A Very Subtle Bug - Made of Bugs

Tags: tech, bug, debugging, system, unix

Interesting subtle differences between gzip and Python expectations which leads to a tough integration bug to find.


Push Ifs Up And Fors Down

Tags: tech, programming

Interesting heuristic to improve code structure. I definitely recommend. As every heuristic it’s not a law though, don’t overdo it either.


TDD Outcomes - by Kent Beck - Software Design: Tidy First?

Tags: tech, design, tdd, craftsmanship, quality

Good summary that TDD is many things… it helps for quite a few dimensions of writing code, still, it’s not a magic bullet in term of design. Your software design abilities are crucial to practice it well.


5 Skills the Best Engineers I Know Have in Common

Tags: tech, engineering, productivity, leadership, tech-lead

Interesting list. Definitely good things to try to learn there.


Minimize global process | Organizing Chaos

Tags: tech, organization, consistency, autonomy

This is a constant trade-off to find. How in organizations give autonomy while ensuring some consistency? A couple of ideas.


Your Small Imprecise Ask Is a Big Waste of Their Time | Stay SaaSy

Tags: management, decision-making

Yes, seen this kind of imprecise requests go wrong fairly quickly more than once. It requires constant awareness though, on both sides of each request. This can be taxing, so no wonder we often drop the ball.


How to Boss Without Being Bossy – Holy Ghost Stories

Tags: management

Interesting taxonomy on how to request things from people. Lot’s to mull over in there.


How to Build Trust - Jacob Kaplan-Moss

Tags: management, trust

Good piece, this is indeed essential in managing others. If they can’t trust you then fear will ensue.


4.5 Billion Years in 1 Hour - YouTube

Tags: science

They really outdid themselves this time. One hour of bliss, it’s really well done.


Bye for now!

Categories: FLOSS Project Planets

Real Python: The Real Python Podcast – Episode #181: Computational Thinking & Learning Python During an AI Revolution

Planet Python - Fri, 2023-11-17 07:00

Has the current growth of artificial intelligence (AI) systems made you wonder what the future holds for Python developers? What are the hidden benefits of learning to program in Python and practicing computational thinking? This week on the show, we speak with author Lawrence Gray about his upcoming book "Mastering Python: A Problem Solving Approach."

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

PyCharm: PyCharm 2023.3 EAP 7 Is Out!

Planet Python - Fri, 2023-11-17 04:42

You can download the build from our website, get it from the free Toolbox App, or update to it using snaps if you’re an Ubuntu user.

Download PyCharm 2023.3 EAP

The seventh build of the Early Access Program for PyCharm 2023.3 brings improvements to:

  • Django Structure view.
  • Search Everywhere.
  • Support for nested classes in HTML completion.
  • Angular 17 support.

These are the most important updates for this build. For the full list of changes in this EAP build, read the release notes.

We’re dedicated to giving you the best possible experience, and your feedback is vital. If you find any bugs, please report them via our issue tracker. And if you have any questions or comments, feel free to share them in the comments below or get in touch with us on X (formerly Twitter).

Categories: FLOSS Project Planets

PyBites: Salary Negotiation Tips

Planet Python - Fri, 2023-11-17 04:13

How to better negotiate your salary? Our new podcast episode offers practical tips!

Listen here:

Or on YouTube:

In this week’s podcast episode we tune into a PDM Mindset Hacking call where Julian offers the group some valuable tips when it comes to negotiating your salary when applying for jobs. 

These tips will help you determine what your worth is and better negotiate as a professional developer.

00:00 Intro
00:59 Preparation, do your research
03:30 Have your portfolio ready
04:13 Know your worth
05:58 What do you need?
08:20 Good prep instills confidence
09:40 Other benefits and perks
10:46 Advocate for yourself based on evidence
12:45 Understanding the role you’re going for
13:50 Know where to stop
14:30 70% is prep
14:55 Wrap up

Our coaching goes beyond only tech + Python; we also coach people on mindset, which often is the missing piece to unlock new levels in their developer careers.

For more information, check out our PDM program.

Learn how Pybites can help you succeed in your Python journey
Join our Python Developer Community for free

Categories: FLOSS Project Planets

Marcos Dione: is-dinant-dead-or-a-tip-for-writing-regular-expressions

Planet Python - Fri, 2023-11-17 03:33

NE: Another dictated and quickly revised post. Sorry for the mess.

Last night I was trying to develop a Prometheeus exporter for Apache logs. There's only one already written but it doesn't provide much information, and I just wanted to try myself (yes, a little NIH).

So I decided to start with the usual thing; that is, parsing the log lines. What's the best thing to do this than regular expressions and since I needed to capture a lot of stuff, and then be able to reference them, I thought "Oh yeah, now I remember my project dinant. What happened with it?"

I opened the last version of the source file and I found out that it's incomplete code and it's not in a good shape. So I said "look, it's too late, I'm not going to put it back in shape this because, even if I'm doing this for a hobby, eventually I will need this for work, so I will try to get something quick fast, and then when I have the time I'll see if I can revive dinant". So the answer to the title question is "maybe".

One of the ideas of dinant was that you would build your regular expressions piece by piece. Because it provides blocks that you could easily combine, that made building the regular expression easy, but it doesn't mean that you cannot do that already. For instance the first thing I have to parse is an IP address. What's an IP address? It's four octets joined by three dots. So we just define a regular expression that matches the octet and then a regular expression that matches the whole IP. Then for the rest of the fields of the line I kept using the same idea.

Another tip is that for defining regular expressions I like to use r-strings, raw strings, so backslashes are escaping regular expression elements like . or * and not escaping string elements like \n or \t, and given that they are prefixed by r, to me it's not only a raw string but it's also a regular expression string :)

Finally, building your regular expressions block by block and then combining them in a final regular expression should make your regular expressions easier to test, because then you can you can build test code that test each block individually, and then you test bigger and bigger expressions, exactly like I did for dinant.

Here's the regexps quite well tested:

import re capture = lambda name, regexp: f"(?P<{name}>{regexp})" octect = r'([0-9]|[1-9][0-9]|1[0-9]{1,2}|2[0-4][0-9]|25[0-5])' assert re.fullmatch(octect, '0') is not None assert re.fullmatch(octect, '9') is not None assert re.fullmatch(octect, '10') is not None assert re.fullmatch(octect, '99') is not None assert re.fullmatch(octect, '100') is not None assert re.fullmatch(octect, '255') is not None assert re.fullmatch(octect, '-1') is None assert re.fullmatch(octect, '256') is None IPv4 = r'\.'.join([octect] * 4) # thanks to r'', the \ is a regexp escape symbol, not a string escape symbol assert re.fullmatch(IPv4, '') is not None assert re.fullmatch(IPv4, '') is not None assert re.fullmatch(IPv4, '255.255.255') is None assert re.fullmatch(IPv4, '255.255') is None assert re.fullmatch(IPv4, '255') is None

Meanwhile, after reading this, I decided to just use the grok exporter. More on that soon.

python dinant regexp prometheeus apache

Categories: FLOSS Project Planets

Reproducible Builds (diffoscope): diffoscope 252 released

Planet Debian - Thu, 2023-11-16 19:00

The diffoscope maintainers are pleased to announce the release of diffoscope version 252. This version includes the following changes:

* As UI/UX improvement, try and avoid printing an extended traceback if diffoscope runs out of memory. This may not always be possible to detect. * Mark diffoscope as stable in setup.py (for PyPI.org). Whatever diffoscope is, at least, not "alpha" anymore.

You find out more by visiting the project homepage.

Categories: FLOSS Project Planets

Andy Wingo: a whiff of whiffle

GNU Planet! - Thu, 2023-11-16 16:11

A couple nights ago I wrote about a superfluous Scheme implementation and promised to move on from sheepishly justifying my egregious behavior in my next note, and finally mention some results from this experiment. Well, no: I am back on my bullshit. Tonight I write about a couple of implementation details that discerning readers may find of interest: value representation, the tail call issue, and the standard library.

what is a value?

As a Lisp, Scheme is one of the early "dynamically typed" languages. These days when you say "type", people immediately think propositions as types, mechanized proof of program properties, and so on. But "type" has another denotation which is all about values and almost not at all about terms: one might say that vector-ref has a type, but it's not part of a proof; it's just that if you try to vector-ref a pair instead of a vector, you get a run-time error. You can imagine values as being associated with type tags: annotations that can be inspected at run-time for, for example, the sort of error that vector-ref will throw if you call it on a pair.

Scheme systems usually have a finite set of type tags: there are fixnums, booleans, strings, pairs, symbols, and such, and they all have their own tag. Even a Scheme system that provides facilities for defining new disjoint types (define-record-type et al) will implement these via a secondary type tag layer: for example that all record instances are have the same primary tag, and that you have to retrieve their record type descriptor to discriminate instances of different record types.

Anyway. In Whiffle there are immediate types and heap types. All values have a low-bit tag which is zero for heap objects and nonzero for immediates. For heap objects, the first word of the heap object has tagging in the low byte as well. The 3-bit heap tag for pairs is chosen so that pairs can just be two words, with no header word. There is another 3-bit heap tag for forwarded objects, which is used but the GC when evacuating a value. Other objects put their heap tags in the low 8 bits of the first word. Additionally there is a "busy" tag word value, used to prevent races when evacuating from multiple threads.

Finally, for generational collection of objects that can be "large" -- the definition of large depends on the collector implementation, and is not nicely documented, but is more than, like, 256 bytes -- anyway these objects might need to have space for a "remembered" bit in the object themselves. This is not the case for pairs but is the case for, say, vectors: even though they are prolly smol, they might not be, and they need space for a remembered bit in the header.

tail calls

When I started Whiffle, I thought, let's just compile each Scheme function to a C function. Since all functions have the same type, clang and gcc will have no problem turning any tail call into a proper tail call.

This intuition was right and wrong: at optimization level -O2, this works great. We don't even do any kind of loop recognition / contification: loop iterations are tail calls and all is fine. (Not the most optimal implementation technique, but the assumption is that for our test cases, GC costs will dominate.)

However, when something goes wrong, I will need to debug the program to see what's up, and so you might think to compile at -O0 or -Og. In that case, somehow gcc does not compile to tail calls. One time while debugging a program I was flummoxed at a segfault during the call instruction; turns out it was just stack overflow, and the call was trying to write the return address into an unmapped page. For clang, I could use the musttail attribute; perhaps I should, to allow myself to debug properly.

Not being able to debug at -O0 with gcc is annoying. I feel like if GNU were an actual thing, we would have had the equivalent of a musttail attribute 20 years ago already. But it's not, and we still don't.


So Whiffle makes C, and that C uses some primitives defined as inline functions. Whiffle actually lexically embeds user Scheme code with a prelude, having exposed a set of primitives to that prelude and to user code. The assumption is that the compiler will open-code all primitives, so that the conceit of providing a primitive from the Guile compilation host to the Whiffle guest magically works out, and that any reference to a free variable is an error. This works well enough, and it's similar to what we currently do in Hoot as well.

This is a quick and dirty strategy but it does let us grow the language to something worth using. I think I'll come back to this local maximum later if I manage to write about what Hoot does with modules.


So, that's Whiffle: the Guile compiler front-end for Scheme, applied to an expression that prepends a user's program with a prelude, in a lexical context of a limited set of primitives, compiling to very simple C, in which tail calls are just return f(...), relying on the C compiler to inline and optimize and all that.

Perhaps next up: some results on using Whiffle to test Whippet. Until then, good night!

Categories: FLOSS Project Planets

Lullabot: Lullabot Podcast: AI in Action: Navigating Generative Tech at Lullabot

Planet Drupal - Thu, 2023-11-16 13:54

Host Matt Kleve assembles a crack team of Lullabot experts from various company departments to share their hands-on experiences and insights into how innovative technology influences and enhances our field.

We discuss integrating AI into coding, design, and tasks like writing emails and RFP responses, along with the broader implications for the future of web development.

Join us as we navigate the complexities, challenges, and vast potential of Generative AI in shaping our world.

Categories: FLOSS Project Planets

Test and Code: 209: Testing argparse Applications

Planet Python - Thu, 2023-11-16 10:50

How do you test the argument parsing bit of an application that uses argparse?

This episode covers:

  • Design for Test: Structuring your app or script so it's easier to test.
  • pytest & capsys for testing stdout
  • Adding debug and preview flags for debugging and testing
  • And reverting to subprocess.run if you can't modify the code under test

Also, there's a full writeup and code samples available:

The Complete pytest Course

  • For the fastest way to learn pytest, go to courses.pythontest.com
  • Whether your new to testing or pytest, or just want to maximize your efficiency and effectiveness when testing.
<p>How do you test the argument parsing bit of an application that uses argparse?</p><p>This episode covers:</p><ul> <li>Design for Test: Structuring your app or script so it's easier to test.</li> <li>pytest &amp; capsys for testing stdout</li> <li>Adding debug and preview flags for debugging and testing</li> <li>And reverting to subprocess.run if you can't modify the code under test</li> </ul><p>Also, there's a full writeup and code samples available:</p><ul> <li>Blog post: <a href="https://pythontest.com/testing-argparse-apps/">Testing argparse Applications</a> </li> <li><a href="https://github.com/okken/test-argparse-apps-hello-world">Code Repo</a></li> </ul> <br><p><strong>The Complete pytest Course</strong></p><ul> <li>For the fastest way to learn pytest, go to <a href="https://courses.pythontest.com/">courses.pythontest.com</a> </li> <li>Whether your new to testing or pytest, or just want to maximize your efficiency and effectiveness when testing.</li> </ul>
Categories: FLOSS Project Planets

Brian Okken: Testing argparse Applications

Planet Python - Thu, 2023-11-16 10:20
I was asked recently about how to test the argument parsing bit of an application that used argparse. argparse is a built in Python library for dealing with parsing command line arguments for command line interfaces, CLI’s. You know, like git clone <repo address>. git is the application. <repo address> is a command line argument. clone is a sub-command. Well, that might be a bad example, as I’m not going to use subcommands in my example, but lots of this still applies, even if you are using subcommands.
Categories: FLOSS Project Planets

cyberschorsch.dev: Introducing the Monitoring Ntfy.sh Integration Module: Real-time Notifications for Drupal Monitoring

Planet Drupal - Thu, 2023-11-16 09:37
Empower your Drupal site with instant notifications using the Monitoring Ntfy.sh Integration module. My new module seamlessly integrates with Ntfy.sh, allowing you to receive real-time alerts and updates based on your Drupal site's monitoring results. Learn how to enhance your site's monitoring capabilities and stay informed with timely notifications in my blog post.
Categories: FLOSS Project Planets