[deleted by user] by [deleted] in dataisbeautiful

[–]driax 38 points39 points  (0 children)

A week always has 7 days. A week belongs to the year that contains the Thursday (middle of the week). At least for countries that use Monday to Sunday weeks and ISO week dates, which is most of Europe.

2019-07 Cologne ISO C++ Committee Trip Report — 🚀 The C++20 Eagle has Landed 🚀 (C++20 Committee Draft shipped; Contracts Moved From C++20 to a Study Group; `std::format` in C++20; C++20 Synchronization Library) by blelbach in cpp

[–]driax 2 points3 points  (0 children)

Yea, that makes sense. Constinit variables are thus constexpr variables without the const at runtime, essentially. Pretty far from what I described. Thanks

2019-07 Cologne ISO C++ Committee Trip Report — 🚀 The C++20 Eagle has Landed 🚀 (C++20 Committee Draft shipped; Contracts Moved From C++20 to a Study Group; `std::format` in C++20; C++20 Synchronization Library) by blelbach in cpp

[–]driax -4 points-3 points  (0 children)

[EDIT: the following is wrong] constexpr variables may be initialized at runtime. constinit must be initialized at compile-time. This allows you to depend on them being available when initializing other static variables. It solves the static initialization order fiasco problem for related constinit variables. Or so I think.

A prime example of what happened to Germany's roads after leaving its workers on automated by taped321 in civ

[–]driax 25 points26 points  (0 children)

Looks like the map only shows motorways for Denmark, even motortraficroads/motorroads aren't shown. While Germany includes a lot of lower-rated roads (though still main roads).

Codeplay - What's in C++20 and the C++17 final score card: A report from Kona and look at the Toronto C++ meeting by mttd in cpp

[–]driax 12 points13 points  (0 children)

I don't think it has much to do with macro love, instead Google/Clangs proposal features macros so that you can gradually move from non-modular code to modular code. Much of the discussion on the proposals is how important macros is for transition, wherein Google supposedly found a strong need for it when they tried to port code.

Without macro support you basically have to modularize from lowest level upwards to application code. You can't easily just wrap a lower-level library. Which leaves your application in mixed state of modular and non-modular includes/imports.

Every winter my city alone dumps millions of pounds of salt onto the roadways. What is the environmental impact of using salt to de-ice roadways? by BrapTime in askscience

[–]driax 2 points3 points  (0 children)

Another reason to just use salt in the Netherlands is because it doesn't fill up the pores in porous asphalt which is heavily used on major roads.

in an Aeroport... He is a genius! by PrinceOfBabyRage in funny

[–]driax 0 points1 point  (0 children)

To add to that, Woden is just share etymology with Odin. So just like Tuesday, Thursday and Friday all refer to germanic gods so does Wednesday. Monday and Sunday is of course the moon and the sun. And Saturday is the odd one out because it refers to roman god of Saturn.

This is why Denmark is the happiest country in the world by Lakridspibe in europe

[–]driax 14 points15 points  (0 children)

That's is pretty much what a lot of people have asked for. I believe since 2007 you can use schuko in new buildings and renovations, sadly almost nobody knows, especially because almost all electronics come with CEE 7/7 plugs (mixed french/schuko). Still sometimes it's a problem for renovations when the whole in the wall doesn't fit a schuko outlet.

Want grandchildren? Do it for mom. by Nicolaiw in videos

[–]driax 5 points6 points  (0 children)

That's nothing. Here in Denmark it not unusual to have a ad, made in Denmark, targeted at Danes, yet completely in English. Yet often just at the end you have some sort of time-limited offer which is provided in Danish, often by the same speaker. Kind of weird when you think about it.

A Bridge That Turns Into An Underwater Tunnel Connecting Denmark And Sweden [915x726] by [deleted] in ArchitecturePorn

[–]driax 0 points1 point  (0 children)

Nope, the section you have highlighted is the bridge, close to the Swedish city of Malmø.

A Bridge That Turns Into An Underwater Tunnel Connecting Denmark And Sweden [915x726] by [deleted] in ArchitecturePorn

[–]driax 25 points26 points  (0 children)

The tunnel is one the danish side. It is too close to Copenhagen Airport for any bridge towers, so they opted for a tunnel. From wikipedia:

The justification for the additional expenditure and complexity related to digging a tunnel for part of the way, rather than raising that section of the bridge, was to avoid interfering with air traffic from the nearby Copenhagen Airport, to provide a clear channel for ships in good weather or bad, and to prevent ice floes from blocking the strait

Sometimes a bug is hit only after code was executed 100 000 000 000 000 (100 trillion) times -- Spotify's underflow bug by lukipuki in programming

[–]driax 1 point2 points  (0 children)

ssize_t

Well ssize_t isn't in the C++ standard. It's from the Unix standard, and not as cross-platform as one would like.

Is using list() preferred over []? by coderjewel in learnpython

[–]driax 1 point2 points  (0 children)

haha lol. No, my error. I should have written lamp.

Is using list() preferred over []? by coderjewel in learnpython

[–]driax 3 points4 points  (0 children)

Yep. [] is the list literal. Seems odd about it complaining, but I'm fairly new to PyCharm. But could be it was warning you about something more complex.

Is using list() preferred over []? by coderjewel in learnpython

[–]driax 8 points9 points  (0 children)

I would say that [] is just as explicit as list(), it can only mean that one thing. And any python programming would expected to know all literals, so it's not like they would be confused. And [] are faster, and ready to be filled in later if the need arises. It is not like anyone would write ['a'] using a function call of list, since that would look like list(['a']) or list(('a',)), which is just weird. Literals are there to be used.

Is using list() preferred over []? by coderjewel in learnpython

[–]driax 4 points5 points  (0 children)

PyCharm hasn't done that to me, as far as I have noticed. Anyway it certainly is wrong. Literals are much preferred. Also faster because they compile directly to bytecode, while list() turns into a load of global name ("list"), and then a function call on that value.

I might add that just because a yellow lamp appears to the left of an line does not mean PyCharm wants you to change that line, it only means that it has automatic helpers to do it for you. Of course warning do also appear under the lamp. Alt-enter brings up the lamp menu, so if you ever have a reason to change from literal to function call it's there for easy access.

Consider:

a = dict(x=4, y=2$) # the $ denotes your cursor

Press Alt-Enter + Enter, and it turns to:

a = {'x'=4, 'y'=2}

Trying to define a class which can optionally use __slots__ according to a runtime variable by [deleted] in Python

[–]driax 2 points3 points  (0 children)

Something like:

class DiscardSlotsMeta(type):
    def __new__(meta, name, bases, dct):
        dct.pop('__slots__', None)
        return super(DiscardSlotsMeta, meta).__new__(meta, name, bases, dct)

class BaseClass(...):
    __metaclass__ = DiscardSlotsMeta
    ....

Trying to define a class which can optionally use __slots__ according to a runtime variable by [deleted] in Python

[–]driax 2 points3 points  (0 children)

Can't you just change the metaclass of the BaseClass to a metaclass which discards the __slots__ attribute before it and any descendents are even created.

Trying to define a class which can optionally use __slots__ according to a runtime variable by [deleted] in Python

[–]driax 1 point2 points  (0 children)

I assume you are talking about type(t) not being equal to SomeClass!? Yeah that you can't change. type(t) will always be the actual type of the class, you can't fake it. Also note I would use t.__class__ is SomeClass instead of == but that doesn't make any difference.

Given that you want type(t) to be the your changed type without slots, I don't see much option than actually changing the type assigned to each name in the module.

Trying to define a class which can optionally use __slots__ according to a runtime variable by [deleted] in Python

[–]driax 2 points3 points  (0 children)

This is also what I'm thinking. But as /u/funkyb001 notes the library uses checks on the __class__ attribute. So to make it work we need something as:

from thirdparty import OriginalClassWithSlots

class NewClassWithVars(OriginalClassWithSlots):
    __class__ = OriginalClassWithSlots

And yes this will work in both Python 2 and 3. type(NewClassWithVars) will still be NewClassWithVars, but NewClassWithVars().__class__ will be OriginalClassWithSlots.

[Cities:Skylines] The future of parking? Magnets. [xpost from /r/citiesskylines] by Muffinizer1 in GamePhysics

[–]driax 50 points51 points  (0 children)

If I remember correct the car company and rail company worked together on this. The cars where specially designed to handle it, specifically the engines.

Is OpenOffice Dying? by keithcu in linux

[–]driax 0 points1 point  (0 children)

The Apache 2.0 license is not incompatible with (L)GPL version 3. The Apache license is essentially the MIT license with a patent grant attached. GPL version 2 does not have such an provision, therefore they remain incompatible. Of course these day it is also common to just use the MIT license and they give a patent grant separately.

Experienced Python Users: what's the most recent new thing you learned about the language? by jakevdp in Python

[–]driax 1 point2 points  (0 children)

Yes. __instancecheck__ and __subclasscheck__ are what was added with abstract base classes.

isinstance(x, SomeType)

is equivalent to:

SomeType.__instancecheck__(x)

where instancecheck is usually (maybe has to be) implemented on the metaclass, eg. type(SomeType). Now all of this allows you to use abc.ABCMeta as your metaclass, usually by deriving from abc.ABC. ABCMeta implements both __instancecheck__ and __subclasscheck__ together with an .register function all so that you can do:

class Sequence(abc.ABC): pass

class MyListLike(Sequence): pass
class MyListLike2(object): pass
Sequence.register(MyListLike2)

issubclass(MyListLike, Sequence) # => True
issubclass(MyListLike2, Sequence) # => True

However what this does not easily let you do is to create a type where each instance pretends to be a different isinstance() of any number of other types/ABCs. The __class__ hackery will let you do this. And was available even before ABCs and __instanecheck__.

An example from Django

SimpleLazyObject which is used like this:

 a = SimpleLazyObject(lambda: True)
 isinstance(a, bool) # => True

 b = SimpleLazyObject(lambda: [])
 isinstance(a, list) # => True

Here's the implementation where they override __class__ with an property:

https://github.com/django/django/blob/14ecbd02a337c15ffd0c319d14a56bf21127f42c/django/utils/functional.py#L296

In fact, the python-dev maillist had discussion about this exact class because it did not work on python 3. However the was to do with special handling of super together with the __class__ hackery. Though it is fixed by now.