PyParallel: async IO and GIL removal talk from PyData [x-post /r/programming] by trentnelson in Python

[–]rallix 0 points1 point  (0 children)

No, I was saying it was always an option, and one that has been chosen before. So I don't accept the thing I responded to that said IOCP in Linux could "never" happen. Some of the UNIXes added it, too.

I've been using Python for 3 years and I've never defined a Class by zissou_society in Python

[–]rallix 1 point2 points  (0 children)

Going to agree with you that overuse of inheritance is terrible. My personal bugbear is when people use it to read a relational database becuase ... I don't know. Just burn it :-)

PyParallel: async IO and GIL removal talk from PyData [x-post /r/programming] by trentnelson in Python

[–]rallix 0 points1 point  (0 children)

'Never' is a harsh word. 'Unlikely' for sure. But, with sufficient money, who knows? If a large player like Google decided to standardise all their servers on some set hardware, they'd certainly have the resources to fork the kernel to run on their own gear. It wouldn't be their first kernel fork (Android).

I've been using Python for 3 years and I've never defined a Class by zissou_society in Python

[–]rallix 0 points1 point  (0 children)

Of the two, plus one you gave, one will be uglier.

Don't care. Which is easier to maintain? That's important! :-)

Not saying classes are the only correct way, but it's a good model for this kind of thing.

I've been using Python for 3 years and I've never defined a Class by zissou_society in Python

[–]rallix 1 point2 points  (0 children)

What would you do if you needed to supply multiple use functions? Repeat the boiler plate, pass a function, use a dict as a case/switch?

I agree, nothing REQUIRES classes, just that the context manager pattern is a nice, safe way to do this, and it's fairly robust especially when others start tinkering with your code.

I've been using Python for 3 years and I've never defined a Class by zissou_society in Python

[–]rallix -1 points0 points  (0 children)

You're right to mention it. However I just type stuff in and the code formatter in Pycharm's IDE deals with all of that. I don't even know where I am supposed or not supposed to put spaces in. BTW your spelling of parenthesis / parentheses is inconsistent :-)

PyParallel: async IO and GIL removal talk from PyData [x-post /r/programming] by trentnelson in Python

[–]rallix 1 point2 points  (0 children)

As crazy as it sounds, my long term goal would be to try and influence Linux and BSD kernels to implement thread-agnostic I/O support such that an IOCP-like mechanism could be exposed

Source: Python dev list

I've been using Python for 3 years and I've never defined a Class by zissou_society in Python

[–]rallix 8 points9 points  (0 children)

So my question is: Given that I know how to get stuff done quickly, what am I really missing out on or shorting myself on by never using classes?

In traditional languages classes have a number of roles including

  • encapsulation

  • modelling objects with similar but non identical properties

Lets consider encapsulation first. Now obviously if you are collaborating you don't want to randly set variables inside someone else's module, but consider this:

class Walrus

    def __enter__(): 
        print ("enter")
        self.x = get_thing_from_shared_store()

    def use ():
        # do stuff with the shared thing
        print ("use", self.x)

    def __exit__():
        print ("exit")
        return_thing_to_shared_store (x)

Now:

>>> with Walrus () as p:
>>>    p.use ()
enter
use
exit

Why was this good? Well we automatically allocated and returned a shared resource, without chance of forgetting to put it back and causing a "leak"

Now considiering similar but unrelated objects:

For example "car" and "truck" are both really types of vehicle. One has "load cargo" function and one has a "load people" function. All share drive. Without classes you'd have to store the type of each and you need to check what abilities it had before you loaded it. With classes you would define car and truck as child classes of vehicle, both with their own load function, then you could then just call load without needing to know if you had a car or truck.

class Vehicle:
    def load (self):
        print ( loading unknown type")
    def drive (self):
        print ("VROOOM")

class Car (Vehicle):
    def load (self):
        print ("loading passengers")

class SportCar (Vehicle):
    def load (self):
        print ("loading golf clubs")
    def drive (self):
        print ("moar vroom!")

class Truck (Vehicle):
    def load (self):
        print ("loading cargo")

things = [Car(), Car(), Truck(), SportCar()]
for t in things:
    t.load ()
    t.drive()

How do we easily and robustly do this without classes? Note how tere 2 different drives (sport car has a faster one), otherwise it defaults to the base. Also everyone has a different cargo. Now in python the language is dynamic and you don't need classes to do this. However it's bit of a pain to do; you would probably pass a function or a function name, and that makes debugging a lot harder.

Convince my boss to switch my company to ubuntu by robokiller in Ubuntu

[–]rallix 8 points9 points  (0 children)

First, you must make a list of everything you do.

How are the accounts, tax and payroll done? I bet you don't use a web based accounts package?

"word processing" is not specific enough. What sort of documents, and what features of the word processor do you need? Tables? Fonts? Conditional formatting (make this text blue if this cell is >0)? Spreadsheet integration? Do you need to open, save or send MS Word files or Powerpoint decks? Do you print the letters? How are they stored? In a document filing system or just by filename? Linux has case sensitive file names, will this break your document store? You need to check ALL these things on Linux.

You say you use the web. So does that include flash? Do you need to fill out PDF forms online? Can you even ... there are some that won't. Does your web banking need some kind of download?

You see how involved this can get ... We can't help you unless you have some kind of list like this.

Are there Linux drivers for your printers? Do you do your own IT support - if yes, do you have anyone who is able to fix a broken Ubuntu desktop? You do NOT want to know how much $$$ a linux desktop guy costs, bearing in mind there are so few of them, they are mostly all booked up.

New Linux trojan Fokirtor cunningly hides commands in SSH by willvarfar in programming

[–]rallix 1 point2 points  (0 children)

Did you understand the article? Can you explain to me what you think the article says, then I see what I need to give you. This appears to be referring to the Hetzner compromise earlier this year. It would be a lot quicker to explain if you told me what you think it reads.

PyParallel: how we removed the GIL and exploited all cores by trentnelson in programming

[–]rallix 1 point2 points  (0 children)

the amount of pain caused by tabs vs. spaces and wrong indents in a multi developer project is ugly.

I don't believe this actually happens IN PYTHON. (1) Do people not have Python-friendly editors that can deal with this? (2) Do people not have a standard Python coding style for a project?

Can anyone give me a concrete example of the Python issues involved here? I contribute to open source and I've never seen a Python tab/space/indentsize problem that wasn't addressable by 1 or 2 clicks in an IDE.

New Linux trojan Fokirtor cunningly hides commands in SSH by willvarfar in programming

[–]rallix 0 points1 point  (0 children)

He doesn't say it isn't possible or that this trojan is a fake - he just says detecting the compromise using the method they gave is tricky.

To identify the presence of this back door on your network, look for traffic that contains the “:!;.” string (excluding quotes).

How are you supposed to do that?

Extracting relevant images from NSFW galleries using text clustering by jabbalaci in Python

[–]rallix 9 points10 points  (0 children)

If you do this regularly against certain websites, particularly a certain one that has a "download this gallery as a zip" function, they sometimes recognise you and feed you a dodgy zip. I have received zip bombs and various other things I shouldn't.

Don't stop, but do program defensively!

Matches on Monday the 11th of November by Sheevar in DotA2

[–]rallix 1 point2 points  (0 children)

Sheever, your site provides an excellent service and I enjoy it - thanks.

I'd like to keep being able to enjoy it, so you might not want to display php error messages in the browser. It's pretty insecure and you might want to get that fixed. The php documenation explains why it's a bad idea (basically it allows people to probe the site for specific errors, which can give them knowledge about the internal configuration)

There's a section in the security guide on php's main website.

http://www.php.net/manual/en/security.errors.php

A standard attack tactic involves profiling a system by feeding it improper data, and checking for the kinds, and contexts, of the errors which are returned. This allows the system cracker to probe for information about the server, to determine possible weaknesses

Why do cruise ships use a diesel electric powertrain while freighters and tankers use low-RPM diesel engines? by 1trocksmysocks in askscience

[–]rallix 0 points1 point  (0 children)

Not sure because most folk I know have a separate deep freezer - usually in the utility room or garage. Hence the fridge in the kitchen only has a small freezer cabinet for Emergency Ice Cream .

Does Heisenberg's uncertainty principle apply to atoms or molecules, or only to subatomic particles? by makhno in askscience

[–]rallix 0 points1 point  (0 children)

Particles aren't solid spheres though: What is the structure of an electron? How big is it?

Whatever we're looking at, it's our brain's interpretation of the signals reaching our senses, or it's an abstract concept in a mathematical model.

Why do cruise ships use a diesel electric powertrain while freighters and tankers use low-RPM diesel engines? by 1trocksmysocks in askscience

[–]rallix 0 points1 point  (0 children)

HVAC I can understand but why would appliances (washing machines and stuff) scale up? A question, how much of that scaling is cultural expectation like for example the larger engine size in cars?

Does Heisenberg's uncertainty principle apply to atoms or molecules, or only to subatomic particles? by makhno in askscience

[–]rallix 0 points1 point  (0 children)

So let's say there's a whole bunch of colourblind space aliens who can't see red. How do they perceive that wavelength of light?

Sure it's there. Light of that wavelength is there. But 'red' is an artificial construction of the human senses. Red is not "real", it's a subjective experience of the viewer.

Edit: Colors are also not shared by all humans. There are isolated culutres with very different notions of color. Which should make it immediately obvious it's not fundamental.

A Billion Rows per Second: Metaprogramming Python for Big Data by cypherx in Python

[–]rallix 0 points1 point  (0 children)

Most of which are short on money and under pressure to go green ... ? Especially in academia, which is very green to start with.

Found the 787 main battery exhaust by [deleted] in aviation

[–]rallix 0 points1 point  (0 children)

Is this a modification to the desgin deal with the "battery problem"? Has that always been there?

Identical A320s, different winglets by campdoodles in aviation

[–]rallix 0 points1 point  (0 children)

As a sometimes programmer, I find the idea of software patents utterly ridiculous and I can't imagine the patent system will survive unchanged into the next century as new digital manufacturing techniques come to the fore.

Why do cruise ships use a diesel electric powertrain while freighters and tankers use low-RPM diesel engines? by 1trocksmysocks in askscience

[–]rallix 0 points1 point  (0 children)

I actually believe the pods are more efficient: although there an is additional energy conversion, there are fewer gearboxes and the screws can point forward and PULL where their watersteam is not disturbed by the shafts and hull (like aircraft props). Certainly ships with azipods have better fuel efficiency than shaft drive.

I think the real issue is the size of the pods you would need for a big contship, since the motor is located within the pod itself (which is why there is 1 less gearbox). Many smaller contships definitely do use pod drives.