Better HN
topnewbestaskshowjobs
Log inSign up

BiteCode_dev

24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions

I write to save you time and effort when dealing with Python:

https://www.bitecode.dev/

Email: contact at bitecode.dev

Submissions

3541.

Python Without the GIL in 2021(docs.google.com ↗)

7 points · by BiteCode_dev · 5y ago · 1 comment

comment 5y ago · link · parent

Doesn't matter, the PSF is not for profit. If people starts trying to avoid the throttle by using alternatives, it just saves money.

comment 5y ago · link · parent

For 2.:

pip can be configured to use a local warehouse, and there are warehouses that transparently proxy to pypi, but caches any previously fetched result. E.G: https://pypi.org/project/proxypypi/

Since you control it, and it's read only from the outside, you can actually expose it even outside of your network.

But indeed, it must be replicated for npm, cargo, maven, docker...

There is a startup idea here :)

comment 5y ago · link · parent

If you can give the guarantees and convenience that lease web give, then yes.

Is your bandwidth unmeterred?

Do you have redundancy everywhere, including link and power?

Do you have software to remotely manage the server, including install, reinstall and emergency access?

Can I pay you with the company credit card? Do you provide a billing system with VAT?

If the answers are yes, then congrats, you can open your own hosting business.

But remember next year, the servers will be obsolete.

comment 5y ago · link · parent

Apple is just better at pretending being all in.

They were part of PRISM.

They recently added a systematic scan, compare and report routine to all your pictures.

They forces you to tie your phone to an Apple account just to use it. My android phone doesn't have an account, or even an email linked to it.

Apple now has an entire mesh network of BT devices constantly looking up each others, even if some of them are not connected to internet.

The microphone on the Apple device is always on, to answer to hey siri.

Finally, you can't install a real alternative browser on iOS, so no real privacy addons.

They make big claims about privacy nobody can check because everything is closed source. So you have to just trust them.

"But apple doesn't have an ad business"

Oh but they do. And they don't have to play by their own rules in the app store, and have the right to track users, gather device informations, location, etc. Fun thing is, they start the list of information they collect (https://www.apple.com/legal/privacy/data/en/apple-advertisin...) by stating "Apple-delivered advertising helps people discover apps, products, and services while respecting user privacy".

I don't think they are any better, just different. And better at PR.

comment 5y ago · link · parent

Agreed. In fact, if you do more than 100 requests/minute for the same IP, you should get throttled. If you want out of it, you should pay.

comment 5y ago · link · parent

First, you can't learn anything, you don't have the time, the energy, nor the talent.

Second, it's inefficient. You should leverage humanity experience.

Third, you can learn a lot faster if you start by repeating something without understanding it. Even maths.

So yes, understanding is useful, but doing without understanding is not bad. It's just a tool.

comment 5y ago · link · parent

I immediately got a good impression of their service because their home page loads so fast.

I'm a simple man.

comment 5y ago · link · parent

Wasn't it the code name for Vista ?

comment 5y ago · link · parent

There is no need to end encryption in the USA, because the way they collect the data works around the problem entirely.

With secret subpoenas, gag orders and programs like PRISM, they get what they need directly from the source. Either from the services hosting the data, or the devices producing/receiving the data.

The data is never collected while in transit, when it's encrypted. They got the keys for the servers, and back-doors to our devices. They don't care about encryption at all.

Once again, freedom is not a technical problem:

https://xkcd.com/538/

comment 5y ago · link · parent

It's very, very, expensive. I don't know the details for debian, but pypi.org, hosting python packages, costs $800k/month: https://twitter.com/dstufft/status/1236331765846990848

I imaging debian is also super expensive, and so scaling that must not be easy. Every decision could be thousands of dollars.

comment 5y ago · link · parent

Talking about myself, as a python dev:

- cheap VPS for hosting, postgres for the db, nginx as a proxy, redis for everything else, including caching.

- deploy python projects by packing them as zipapp with shiv, then use fabric to ssh and performs any migrations necessary. No, not even ansible.

- build, lint, format and test, like all automatizable stuff, are made using pydoit. If you are solo, you don't need a CI service. Your laptop is the CI machine.

Scaling is always the same story:

1 - start with the cheapest VPS possible. This will force you to code with some constraints. Not crazy, just enough to balance it out.

2 - once you start seing your load average rising, just move the db on a second cheap VPS. You just tripled the load you can sustain. Not doubled, tripled. Most solo projects will stop here actually.

3 - wait again, collect some perfs data when you see the site starting to be slow. Check for slow queries, code hot paths, etc. Optimize that, add some cache, setup tasks queues. Use cron to purge / regenerate cache if you need to smooth out the curve. Maybe slap some varnish for extra peps, or just cloudflare.

4 - now you got what looks like a real load, and a more realistic code base, so when you peak again, request more perfs for your server, or migrate to another bigger one. You can scale vertically to crazy highs nowadays. Really, really crazy. You can get terabytes of RAM, 64 cores servers, etc. At your current scale, your service should generate enough money to pay 10 times for it anyway. But you probably won't need to. Even cheap servers are beast, look at the current leaseweb offer: https://www.leaseweb.com/dedicated-servers#NL

For €320.09 per month, you get:

    2x 16 cores 2.30GHz
    28GB DDR4
    4x960GB SSD
    30 TB traffic
To put it in context, myspace used to serve all its users with 2 servers only, until they reached 500,000 accounts. Only then it was too much. This was with hardware (and price!) in the years 200x.

5 - you will probably never reach this point. This is the point where kubs, load balancers, sharing, etc. start to be interesting.

How to preserve your data:

- Raid

- Dump the db with a _randomized_ cron

- rsync the dump and all assets. You can do it to another server, or just your laptop at the beginning.

You can get fancy with database replication if you want, or use backups that stream in real time.

But there is one trick: not all data are equal. Identify some data in your db that you can't afford to lose, and make sure this one is saved separately and very regularly while being given priority. There are plenty of data, if you have a hole in it, most people don't care. E.G: if 1 tweet out of million from 10 years ago is missing, do you think it affects the service?

Monitoring:

- Sentry

That's all. It's free (or cheap), and for a small service, you don't need real time. It's ok to be down a few hours once a month for most services at first. I have a service with 700k unique users a day, it still goes down sometimes. It's a blip.

Sometimes, log into the servers, run htop and checks what's up. You can install open telemetry later if you really need to, but for now, even HN hug is not going to kill you.

Summary:

- Modern software and hardware are amazing. Max them out. Horizontal scaling is hard, and expensive.

- You don't need a perfect service. Unless you are handling patient cancer data, that is. Don't worry about perfect uptime, 0 data loss, etc. If you are a solo dev, the cost for that is huge. Just do 97% right⋅

- what worked 20 years ago still work today, and will likely be there tomorrow. And you can move from that to the cloud later. The reverse is not that nice.

comment 5y ago · link · parent

You did that, as a solo dev with little money, and made a profitable business out of it?

comment 5y ago · link · parent

Well, we know that mass surveillance has been installed in the USA, we have detailed proof of it, and this hasn't change a thing. They are still under mass surveillance.

And people are still carrying trackers in their pocker. They put cameras in the front door bell, always online microphones with speech analysis in their living room, give all their life records, textual or in images, to giants companies that have demonstrated the ability to store and analyse that forever.

People don't use more free software. They look at you like you are mad if you don't want to install whatsapp. Even in HN we have people still wondering why we should use Firefox.

Why would we be judging Australians as "complacent" ? Humanity is complacent.

I've been told the boiling frog is a myth, but I'm pretty sure frogs are talking about boiling humans as a telling metaphore.

comment 5y ago · link · parent

Not because the -o mode also remove any block testing on "__debug__", and that's a very useful thing as well.

The original feature is perfect. But there is 5 good years of educating users so it can be used.

comment 5y ago · link · parent

Yes but self driving cars, which could be a solution for this problem since we could then have cars on demand, are way harder to implement using oil than electricity.

comment 5y ago · link · parent

unsafe rust code is not safe, but the rest of the program is, and the unsafe blocks provides very nice benefits:

- limit the size and scope of the unsafe code

- make the unsafe part stand out, "here be dragons", so you know when to be particularly alert

- act as a safe way to encapsulate unsafe code so that it can be used by safe code, and used without the lack of safety propagating outside of the unsafe zone

comment 5y ago · link · parent

Yeah, and didn't seem reluctant at all at the time.

comment 5y ago · link · parent

Don't know, videos are seemless but I got a very powerful CPU.

comment 5y ago · link · parent

"-o" is mostly "--remove-assertions" already, so that wouldn't help.

While today's use case for assert is unit testing, the actual killer feature of the keyword is that it's removed only from prod.

The idea is that you can write things like function contracts, that are expensive, but only exist in dev.

Now, if one of you dependencies use assert for something they expect to still be in prod, which is the problem we are talking about in the first place, "-o" or "--remove-assertions" will strip their assert too, breaking their code, and hence, yours since it depends on it.

comment 5y ago · link · parent

Nope, I just remember my server crashing years ago so I stopped ever since.

Would be interesting to scan pypi and check if this is still a thing.

Maybe create a bot warning lib authors.

comment 5y ago · link · parent

Every single one have fake data, guaranteed. I have yet to see a public facinh site I worked on that didn't have some fake data.

Some outrageously fake, like x10 times the user count.

comment 5y ago · link · parent

Unfortunatly you often can't use -o because of the 3rd party libs that didnt' get the memo and use assert for error checking.

We still have -X dev and sys.flags but it's runtime only.

comment 5y ago · link · parent

It's pretty well done, I almost forgot I was in my shell, and when the games gets to "tree to map the dungeon", I was almost surprised I didn't think about it before: I felt like playing a game, not coding in bash :)

comment 5y ago · link · parent

Yeah, let's stop making murder illegal. I'm sure there is a smart startup that can disrupt it.

comment 5y ago · link · parent

While I do use Firefox on mobile, I'm talking about the desktop version, like most people do.

The latest rendering improvements are showing great results, and hardware acceleration on Linux is now on part with Windows, so it's fantastic to use on a modern laptop.

comment 5y ago · link · parent

You also have the option to live in a cave, or to kill yourself.

But I don't think we should use them in a reasonable argument.

comment 5y ago · link · parent

You can since 3.8 :)

https://docs.python.org/3/library/multiprocessing.shared_mem...

If you use a data structure that supports the buffer protocol (such as a numpy array), you won't even pay a serialization cost.

Python has made a LOT of progress, concurrency wise. Between asyncio, process pools, threads releasing the GIL and shared memory, you can get much perfs with the stdlib alone.

Then of course you have Dask if you need more later.

comment 5y ago · link · parent

It's fun and probably useful, but Python is not 30 times slower than lua (from 33s to less than a sec).

The 2 codes don't do the same thing, if you perform the same computation on the python code (monochrome mandelbrot, inline loop, 49 iterations, etc), you get 0.8 vs 4.8 sec, which seems about right.

I've removed numpy since it's cheating if we compare raw language perfs:

https://0bin.net/paste/nOtLmeMA#0DKGHSvmgoDLPzHlQOhwvVhxxayf...

So yes, Python is about 6 times slower. Significative, but can be worth the compromise if you consider the Python version is much, much easier to read.

And of course, a vectorized algo would be even faster (see pbourke's comment).

What's more, with SharedMemory from 3.8, you could speed that up even in pure Python using multiprocessing by sharing efficiently the array.

comment 5y ago · link · parent

The supported python version:

    >>> import tkinter as tk
    >>> tk.Tcl().eval('puts {hello, world}')
    hello, world
    ''
I wonder if this releases the GIL.
1
118119120
184