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

comment 5y ago · link · parent

What was the name of the framework?

comment 5y ago · link · parent

Python added a GOTO a few years ago, by mistake, with asyncio.ensure_future(): https://vorpus.org/blog/notes-on-structured-concurrency-or-g...

We are still paying this mistake as of today: most devs don't scope their async tasks lifecyle leading to a huge spaghetti code.

GOTOs are too easy to misuse.

We used to have only GOTOs, no loop, no if... But specialized keyword are better: they enforce a cleaner code, leverage conventions, play batter with tooling and make the whole experience easier to read and debug.

comment 5y ago · link · parent

That's what functions are for.

And bonus, you can put them in several files, and import them when your program grows. Which means you can then call them in the shell to play with them.

It will make the whole experience much easier.

comment 5y ago · link · parent

> Rephrase any element that suggests certainty

So underrated. Certainty brings sad situation when reality doesn't match the words of a trusted person.

That's probably one of the reason Mr Rogers feels so honest and reliable: it's the reverse of the salesman.

comment 5y ago · link · parent

I'd say it's a good thing people don't try to use the feature in a context it's not useful. Don't use the shiny new toy just to play.

Python has to cater to a vast crowd, and geographers don't have the same needs as data scientists, web devs, 3D artists or sysadmin.

So it's logical some tools will be useful in some cases, and not some others.

Amusingly yesterday I was doing something in JS, and though, "ah, I wish I has this new PM feature from python there".

The day before, I had to deal with pedantic exception, and wish I had a pattern matching to make a case depending of the number of errors and their message. I had to do a hacky loop for something that had to do with structure, not repetition.

Just like the walrus, I don't think it's something that will pop up everywhere, all the time. But when it is useful, it will make the code nicer.

comment 5y ago · link · parent

> but also, 97% of professional Python development is in data-science/application developmen

No. There is not a single field with " 97% of professional Python development". As a freelancer, I see python used for everything, everywhere. From education, to math, to biology, to geography, to web dev, to automation, to testing, to desktop app...

comment 5y ago · link · parent

Give a try to fastapi + vscode with pylance. Eye opening to what you can do if you use modern features right.

comment 5y ago · link · parent

I hear that quite often, but up to now, I haven't seen it translate in the field.

Code examples in docs and tutorials are still easy, libs api still clean, code base still readable.

Optional things stayed indeed, optional.

My grip is actually the contrary, many python code bases are stuck in the past. But I'm ok with it, people are not all pro devs, they need a productive language subset.

And the new syntax is providing some fantastic new tools, such as pydantic/fastapi/typer (if you haven't try it, it's really paradigm shift, and I say that as a django fan). f-string are awesome. dataclasses are nothing but convenient and readable. Advanced unpacking as well. I seldom use the walrus, almost nobody does, but when one does, it's useful.

> decorators, comprehensions,

Those existed in python 2, 10 years ago. It's hardly new python. And web frameworks would be terrible without those.

comment 5y ago · link · parent

That would be at odd with the language style which separate statements from expressions.

You can dislike this language characteristic, but it's the right call to stay congruent.

comment 5y ago · link · parent

> "Seq enables users to write high-level, Pythonic code without having to worry about low-level or domain-specific optimizations, and allows for the seamless expression of the algorithms, idioms and patterns found in many genomics or bioinformatics applications. "

I gave it a look, and indeed it's not complete python, it will break if you start using the language/stdlib features.

Stdlib modules I couldn't import:

- sqlite3

- urllib

- pathlib

- hashlib

- json

Infra unavailable:

- Debug mode

- pip/venv

- shell

Syntax/built in that didn't work:

- byte and complex literals

- type()

- Some unpacking (E.g: [*[0]])

- raise from

- async/await

It also adds incompatible syntax that is not python, such as 's""' and '|>'.

So despite what that the README says "the vast majority of Python programs should work without any modifications", it's actually the opposite.

The project has real value though, you just need to understand that what you buy here.

comment 5y ago · link · parent

I like it, and it's also a good example of why a framework will start to be useful if you get more complex code.

When we arrive at the CRUD widget,a simple <script> dep on petite-vue (6ko: https://github.com/vuejs/petite-vue) would half the implementation by half.

Of course it would still count as more lines of code in total, but not sure that matters.

Anyway, when I teach react/vue, I always start with the vanilla example because just like with ORM, people need to know the benefit and cost of the abstraction.

comment 5y ago · link · parent

I missed that, their offer tamk about wordpress.

comment 5y ago · link · parent

Not really, it does not provide a blog feature, only a bridge.

comment 5y ago · link · parent

With your own domain name and branding, maybe we can play a different game provided the platform is willing to forward complaints to the user and step back.

After all, I'm responsible for my vps content, not my hosting. What's the difference ?

comment 5y ago · link · parent

Numpy does that too, but it's a domain specific lib. I doubt they are speeding up real python itself.

comment 5y ago · link · parent

It's possible, but the alternative is to depend on google for traffic, which is an abusive relationship at this point.

At least if you have are on several platform, there are multiple entre points for your content. And your blog would allow you to offer things that the platform don't, like code snippets, easy media download, or something more innovative.

comment 5y ago · link · parent

If anybody have used it, what's the benefit of it being a DSL, over, say, a regular library?

comment 5y ago · link · parent

> your audience still comments on social media and so your discussion remains there.

Discussion should remain on social media. This avoids the problems of moderation and spam that plagued blogs.

> it is far too simple to just use social media directly

Yes to succeed the blog platform should be super easy to setup and to link.

There are benefits that can then attract people:

- if you have several social accounts, on the same or different platforms, then having a centralized way of publishing on all of them is a nice perk

- social media platform impose a lot of rules, but on your blog, you can do whatever you want. So for problematic content, you can tease on social networks, and bring people on your blog for the real uncensored thing.

- the source of truth that the blog would be is a fine touch in this era of fake news

- you can add paid sections to the blog and make money directly with your biggest fans

comment 5y ago · link · parent

Yes, I think is a need for some platform that provides blog+microblog on your domain, and that automatically forwards the content to social platforms so that you get the best of both worlds:

1 - owning your blog is too big of a barrier of entry, there is a need for a platform: look at the success at medium for tech writers, despite that we hate it.

2 - we need the return of the domain name based blog. This helps with independence, censorship, and the like. You can always move from the platform, and the platform can claim they can't censor you since it's your domain, so DMCA should be sent to you directly.

3 - this platform should do blog + microblog. You don't always have something long to say, announcement, though and quick tips are very well suited to tweets. But only this format leads to quality deficiency. Being able to write a big article easily is equally important.

4 - forwarding all posts to your social networks is essential. Yes, your blog should be the original source (so you get ref, credit, independence and not the duplicate content ban from google). But the discovery problem cannot be solved easily, and those networks already exist.

EDIT: unrelated, but I love phone calls. I mean, I hate doing them, but I love having the ability to do them. It's a universal reliable tech, it works in the country side, it works when the wifi is down, it works well in the car, and I don't have to have the app du jour installed or insist that the other party does.

comment 5y ago · link · parent

> Of course we shouldn't attempt to anthropomorphise animal behaviour

Why not? Our behavior emerged from a primitive animal state. It's not crazy to think it can happen again.

The only mistake would be to pretend it's the definitive answer, but unless we got one, it can be one of the theories.

comment 5y ago · link · parent

Agreed, and I really with partial() was a builtin in Python, instead of having to fetch it from functools. partial() is useful regularly, and much more explicit/flexible than a lambda for this specific use case.

comment 5y ago · link · parent

Excuses accepted. Imperative Python would really look like:

    try:
        return sendEmail(user.email for user in users)
    except IsError:
        Error("Error sending emails") # if it does something
I agree FP pipelines are nice, but not everything needs it.

comment 5y ago · link · parent

> that case watchmedo will trigger pytest to run twice,

That's what the --drop options is for. It's better than delay, since it drops any event while the command is running, no matter the time it took.

> First, I think for many users typing: ... is a lot simpler than typing:...

I think somebody using pytest is perfectly capable of doing:

alias ptw='watchmedo shell-command --patterns="*.py" --ignore-directories --recursive . -c "pytest" --drop'

Or putting that in a makefile, a dodo.py file or what have you.

comment 5y ago · link · parent

1 - it's sandboxed by default

2 - it's the only things that also run on the web

3 - it's probably going to be ubiquitous because of that, meaning it will be a great platform to target by default

4 - it could potentially mean any platform run any code from any other one without having to deal with wrappers: you would write a lib in go or rust, and then run it as is in python

comment 5y ago · link · parent

Honestly, this would have been a great prompt in 1950.

comment 5y ago · link · parent

What's the benefit of doing this instead of just using the watchmedo command from watchdog directly ?

    watchmedo shell-command --patterns="*.py" --ignore-directories --recursive . -c "pytest"
As a bonus, watchmedo works for your server, your bundler, you task queue process, etc.

It seems that there is no need to create one tool per command you wish to run. Or am I missing something? Do you only reload tests that are related to the code change?

comment 5y ago · link · parent

Yep: https://huey.readthedocs.io/en/latest/

comment 5y ago · link · parent

Sensible decision, although hardly a surprise or a killer feature for something that is a major version bump.

I assume the async story is going to be more fun.

By the way, if you are looking for a good key/value store with expiration without the need to setup redis, have a look at the excellent diskcache:

https://pypi.org/project/diskcache/

It is based on sharded sqlite files, and it's surprisingly capable, even in multiprocessing based env like a django site.

Sqlite is really showing up in all sort of use cases these days, like huey, a task queue that doesn't need any broker to be installed to be useful: https://pypi.org/project/diskcache/

Now things can get fun...

With supervisord (supervisord.org) you can manage multiple processes, and with fastapi + starlette, you can serve your WSGI site without a proxy pass, including static sites: https://fastapi.tiangolo.com/advanced/wsgi/

Then with shiv you can bunddle all that in a pyz file: shiv.readthedocs.io/

Meaning you can now just upload a pyz file to your server, run python on it, and that's it, you have a full stack deployed, with a web framework, db, caching, task queues, static file serving, which can handle around 100k visitor each day without a sweat.

No more infra needed. Just Python code, all bundle in one file.

That's really neat.

comment 5y ago · link · parent

First, there are people that don't want to use a CDN (don't trust them with censorship), or can't (local network).

But you can cache other things that are not the entire page itself:

- database queries

- user sessions

- api calls

- page fragment

- function memoization

What's more, cache backends have the ability to expire things, which can be helpful for all sort of stuff.

comment 5y ago · link · parent

Honestly progress doesn't seems slower at all. I hear news of scientific discovery every week. Science is large, and it's not just physics.
1
125126127
184