Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
12 rats tied together
Sep 7, 2006

"python with jit" lives on in pypy

Adbot
ADBOT LOVES YOU

12 rats tied together
Sep 7, 2006

the monorepo is usually a good idea except at the scale google uses it at, that's what's so crazy about this

12 rats tied together
Sep 7, 2006

Captain Foo posted:

gom shaggar

lmfao

12 rats tied together
Sep 7, 2006

in those cases you can use a nonstandard json lib like orjson (rust), ultrajson (c), or rapidjson (c++)

the idea that you shouldn't optimize code in a slow language is absurd

12 rats tied together
Sep 7, 2006

eschaton posted:

some people are so afraid of the “cognitive overhead” of a class (which has a specific purposes and is a nice, central place to consolidate both documentation and behavior) that they insist on using “raw” data structures everywhere and introducing a whole ton of dictionary keys and helper functions instead

the semantics of python docstrings means that you can consolidate behavior and documentation trivially regardless of the conents of a given module, e.g.

Python code:
# some_helper_module.py

from typing import NamedTuple

ExampleThing = NamedTuple("ExampleThing", [("field_name", str)])
"""
    Provides an example of a thing.
    Attributes:
    field_name (str): The name of a field.
"""
any modern python IDE will include the docstring with ExampleThing when it is imported and inspected. the same would apply if we exported an annotated helper function, or an ExampleThing factory, or whatever

obviously, the person or people we're talking about don't exist, and nobody ITT is arguing that you should never use classes in python because of "cognitive overhead", but it is also the case that not everything in python needs to be a class, should be in a class, or even that you should default to putting everything in a class

12 rats tied together
Sep 7, 2006

Carthag Tuek posted:

you can also do it like this:
:tipshat:

cinci zoo sniper posted:

same, also something to type check the rest of the program on initialisation

i have not used it but i understand that beartype is the new not-bad thing for this, which supplants the earlier typeguard project which was occasionally slow enough that you probably shouldnt leave it on in production

12 rats tied together
Sep 7, 2006

the type checks always run but what is actually checked is based on some kind of random tree traversal thing, such that the check always executed in constant time, afaict

for simple use cases -- this needs to accept and return a string -- the type check rate is 100% and the rate at which you catch invalid input or output is also 100%

i am curious about more complex cases and ill prob experiment with it sometime this week.

12 rats tied together
Sep 7, 2006

the triply nested list of all integers one to one billion is clearly a contrived example, but for things like "i have serialized this network request into a dataclass" you would just check that the object is of the type ThatDataclass

this solves basically every runtime typecheck utility i would need, maybe a data science toucher can comment on the numpy array checks because i don't understand that library

12 rats tied together
Sep 7, 2006

pointsofdata posted:

Also lmao how does this even count

It doesn't sound like it really checks anything in this case? Seems obviously worse than not using it I must be misunderstanding

e: https://github.com/beartype/beartype/issues/60

despite this persons writing style being kind of twee, this is honestly one of the best issue responses ive seen for any computer product or library

12 rats tied together
Sep 7, 2006

you will get a lot more mileage out of 200 lines of python than you would out of 200 lines of rust

i have looked at 0 kotlin but since its basically a java dialect i imagine its even worse

12 rats tied together
Sep 7, 2006

i don't entirely disagree but im phone posting so i have to be brief,

1- that statement asserts a level of foreknowledge that if you had, you would be rich enough to be writing 0 code in any language

2- it overestimates the difficulty in migrating away from python, substantially, and assumes the worst possible behavior from the tool authors and users

you clearly have more experience living in this hell than i do, so i will take your word for it that i would regret writing an internal tool in python later when it has infinity users and i have been given 0 budget or time to rewrite

a good thing about this for me specifically is that i just work here, so i can walk out the door and find a job any any one of the thousands of software firms that don't regard their staff with active malice

12 rats tied together
Sep 7, 2006

i realize now that i missed the "the philosophical argument for [...]" prefix of your post and assumed that it was an argument offered in earnest, and not just an example

its a bad argument, it's also "the usual" (which is boring), so i took offense. i should not have, and i am sorry that i did.

12 rats tied together
Sep 7, 2006

what i was getting at with the post you quoted is that there is a continuum of potential complexity for a task that influences what you should use for it, and a joke about how if you're going to draw the line at 200 LoC then you don't want to waste those LoC in rust solving object ownership and type system sudokus for no reason

if that complexity increases later, it can only be better (or same-bad) to have an example to base further iterations on. the only fixed costs are the cost of initial implementation, and the cost of carry, which should both be optimized for at the outset.

it's impossible to optimize for the "cost eventually", and it's impossible to work in a place that puts unbounded demands on some code you wrote in the past while giving you no agency over it. if someone were to let either of these things influence an earnest opinion that they hold, and then proselytize that opinion to others, that would be stupid

12 rats tied together
Sep 7, 2006

doesn't the packet header have a version field? i don't see how that would matter, you would just design it as a protocol that communicates over superficially similar looking packets

routing devices would need an ipWhatever routing table. it doesn't have to intersect with the ip4 routing table

12 rats tied together
Sep 7, 2006

it's kinda like a snapchat operating system

12 rats tied together
Sep 7, 2006

if you were going to do that you would instead just `python -c`. just learn awk, its good and useful, and will save you from creating the n+1th dumb CLI tool at your organization

12 rats tied together
Sep 7, 2006

normally im down with weird markup language poo poo but if you've set out to create a version of xml that is easier for humans to read and write you ought to just use yaml instead

12 rats tied together
Sep 7, 2006

prisoner of waffles posted:

just read more about YAML

kombucha-girl-no.png: arbitrary code exec in Python, lmao
kombucha-girl-maybe.png: IDs for nodes, links to identified nodes

vince-falling-over-backwards.gif: all nodes have a type. ability to define custom types. schemas for placing constraints on nodes and their type.

12 rats tied together
Sep 7, 2006

what do you mean sometimes? sequences like lists use indentation for scope. you can always indent however many times you feel like in YAML, the only rule is that things that share scope (items in the same list) need to be at the same indentation level. you can indent one, two, five hundred spaces, it doesn't matter because indentation is a presentation detail only

12 rats tied together
Sep 7, 2006

Visions of Valerie posted:

code:
- it:
    - absolutely
- isn't
if relative indentation matters, it's not merely a presentation detail

what's your issue with this? you can indent `- absolutely` however many times you want, and it is equivalent.

the only weird part of this snippet is that the mapping value must be indented by >1 blank space character (normally >0 would be fine), but this is likely an artifact of you nesting a block mapping which is distinct from a block sequence and thus has different rules for indentation.

12 rats tied together
Sep 7, 2006

if you can't read a line break as a substitute closing brace or bracket you can just use one of the yaml flow styles which require them.

unfortunately examples in the wild are rare, and many tools will not emit them, because most people dont have this problem

12 rats tied together
Sep 7, 2006

Surprise T Rex posted:

https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell

I don’t think there’s a good config language tbh but if there is yaml doesn’t seem to be it

this article is based on the yaml 1.1 spec which is from 2005.

Adbot
ADBOT LOVES YOU

12 rats tied together
Sep 7, 2006

pyyaml also ships with a schema + loader that loads the entire document without issue
Python code:
> ~ python
Python 3.10.4 (main, May  7 2022, 11:53:57) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.load("""server_config:
# snip
...     - 12.13""", Loader=yaml.BaseLoader)
{'server_config': {'port_mapping': ['22:22', '80:80', '443:443'], 'serve': ['/robots.txt', '/favicon.ico', '*.html', '*.png', '!.git'], 'geoblock_regions': ['dk', 'fi', 'is', 'no', 'se'], 'flush_cache': {'on': ['push', 'memory_pressure'], 'priority': 'background'}, 'allow_postgres_versions': ['9.5.25', '9.6.24', '10.23', '12.13']}}
i recommend reading the documentation for your tools instead of writing the n+1th screed

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply