16 comments

  • axpy9061 minute ago
    When Wes McKinney wrote about the transition away from python I knew it was real. <a href="https:&#x2F;&#x2F;wesmckinney.com&#x2F;blog&#x2F;agent-ergonomics&#x2F;" rel="nofollow">https:&#x2F;&#x2F;wesmckinney.com&#x2F;blog&#x2F;agent-ergonomics&#x2F;</a><p>I still have a special place in my heart for the language and think it’s still got a niche.
  • kokada9 hours ago
    From this example:<p><pre><code> lazy from typing import Iterator def stream_events(...) -&gt; Iterator[str]: while True: yield blocking_get_event(...) events = stream_events(...) for event in events: consume(event) </code></pre> Do we finally have &quot;lazy imports&quot; in Python? I think I missed this change. Is this also something from Python 3.15 or earlier?
    • llimllib8 hours ago
      3.15: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3.15&#x2F;whatsnew&#x2F;3.15.html#whatsnew315-lazy-imports" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3.15&#x2F;whatsnew&#x2F;3.15.html#whatsnew315-...</a>
      • javcasas7 hours ago
        &gt; When an AttributeError on a builtin type has no close match via Levenshtein distance, the error message now checks a static table of common method names from other languages (JavaScript, Java, Ruby, C#) and suggests the Python equivalent<p>Oh, that is such a nice thing.
        • fulafel4 hours ago
          It&#x27;s unrelated to the lazy keyword. Instead it&#x27;s another feature related to error messages.<p>The example:<p><pre><code> &gt;&gt; &#x27;hello&#x27;.toUpperCase() Traceback (most recent call last): ... AttributeError: &#x27;str&#x27; object has no attribute &#x27;toUpperCase&#x27;. Did you mean &#x27;.upper&#x27;?</code></pre>
          • estebank4 hours ago
            In the Rust toolchain we&#x27;ve done the same. It just so happens that rustdoc already has introduced annotations for &quot;aliases&quot; so that when someone searches for push and it doesn&#x27;t exist, append would show up. Having those annotations already meant that bootstrapping the feature to check the aliases during name resolution errors in rustc was almost trivial. I love it when improving one thing improves another indirectly too.<p>I really appreciate them going out of their way to do this, being quite aware of the hidden complexity in doing it.
          • tuveson3 hours ago
            I’ve often thought it would be funny if instead of an error message for stuff like this, a language could be designed to be “typo-insensitive”. If a method or function call is similar enough to an existing one or a common one from other languages, to just have it silently use that.
            • estebank3 hours ago
              VisualBasic did that. I think it is a mistake. But that doesn&#x27;t mean that the compiler can&#x27;t detect that <i>and tell you how to fix it</i> instead.
              • tuveson3 hours ago
                Sure VB ignores case, but what I want is for it to compare each method against a dictionary of similar terms. And maybe calculate the Levenshtein distance between all terms if it’s not found, and just assume it’s the closest one. You could also assume that full-width characters or similar-looking glyphs are equivalent (BASIC was pre-Unicode, so I can forgive them for not including that).
            • QuesnayJr3 hours ago
              Lisp had a package for that, DWIM, in the late 60s: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;DWIM" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;DWIM</a>.
            • MarkusQ3 hours ago
              I hope you mean &quot;funny&quot; in the &quot;hilarity ensues&quot; sense.<p>Because the alternative is a rather sociopathic level of schadenfreude.
              • tuveson3 hours ago
                Yes, I say “funny” because it would be impractical and weird, definitely not a good idea. It’s already a bad enough that so many popular languages don’t (and can’t) check if a field or method is misspelled at compile time…
                • sfink2 hours ago
                  We already have it. In fact, Python added it with this change! Not intentionally, but in a world of AI, any error message containing a suggestion of what to do to fix it is a directive to the AI to actually do that thing.<p>Example: to build our system, you run `mach build`. For faster rebuilds, you can do `mach build &lt;subdir&gt;`, but it&#x27;s unreliable. AI agents love to use it, often get errors that would be fixed by a full-tree build, and will chase their tails endlessly trying to fix things that aren&#x27;t broken. So someone turned off that capability by default and added a flag `--allow-subdirectory-build` for if you want to use it anyway. So that people would know about it, they added a helpful warning message pointing you to the option[1].<p>The inevitable (in retrospect) happened: now the AI would try to do a subdirectory build, it would fail, the AI would see the warning message, so it would rerun with the magic flag set.<p>So now the warning message is suppressed when running under an AI[2][3]. The comment says it all:<p><pre><code> # Don&#x27;t tell agents how to override, because they do override </code></pre> &quot;The user does not want me to create the Torment Nexus but did not specify why it would be a problem, so I will first create the Torment Nexus in order to understand the danger of creating the Torment Nexus.&quot;<p>[1] <a href="https:&#x2F;&#x2F;searchfox.org&#x2F;firefox-main&#x2F;rev&#x2F;fc94d7bda17ecb8ac2fa9a996dd18dde16002374&#x2F;python&#x2F;mozbuild&#x2F;mozbuild&#x2F;controller&#x2F;building.py#1497-1508" rel="nofollow">https:&#x2F;&#x2F;searchfox.org&#x2F;firefox-main&#x2F;rev&#x2F;fc94d7bda17ecb8ac2fa9...</a><p>[2] <a href="https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=2034163" rel="nofollow">https:&#x2F;&#x2F;bugzilla.mozilla.org&#x2F;show_bug.cgi?id=2034163</a><p>[3] <a href="https:&#x2F;&#x2F;searchfox.org&#x2F;firefox-main&#x2F;rev&#x2F;cebc55aab4d2661d1f6c2d1526362947ec4016c1&#x2F;python&#x2F;mozbuild&#x2F;mozbuild&#x2F;controller&#x2F;building.py#1484-1490" rel="nofollow">https:&#x2F;&#x2F;searchfox.org&#x2F;firefox-main&#x2F;rev&#x2F;cebc55aab4d2661d1f6c2...</a>
        • embedding-shape5 hours ago
          Now I&#x27;m wishing for a single cross-language library, that I can somehow inject into every compiler&#x2F;runtime&#x2F;checker to get this, but with a single source of truth and across a wide range of languages. I hit this damn issue all the time, writing code in one language for another, would truly be a bliss to have that problem solved once and for all.
          • estebank4 hours ago
            If you had a &quot;canonical datastructure database&quot;, you could have very short annotations on every standard library for any language that indexes a function to their canonical name. After that you only need to update the database.
    • kzrdude6 hours ago
      What benefit does the lazy import have here - if we use the value in a type hint at module scope anyway? Would that require Deferred evaluation of annotations -- which I don&#x27;t think are enabled by default?
      • js26 hours ago
        Type annotations are lazily evaluated by moving them behind a special annotations scope as of 3.14:<p><a href="https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0649&#x2F;" rel="nofollow">https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0649&#x2F;</a><p><a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;reference&#x2F;compound_stmts.html#annotations" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;reference&#x2F;compound_stmts.html#anno...</a><p>With 3.15, using lazy typing imports is more or less an alternative to putting such imports behind an &quot;if TYPE_CHECKING&quot; guard.
        • kzrdude5 hours ago
          Ah, thanks for the update. My only check before asking was to check if the future feature for annotations had been enabled by default yet. It has then effectively been abandoned instead, I guess.
          • js25 hours ago
            Yup, &quot;from __future__ import annotations&quot; will eventually be removed:<p>&gt; from __future__ import annotations (PEP 563) will continue to exist with its current behavior at least until Python 3.13 reaches its end-of-life. Subsequently, it will be deprecated and eventually removed.
            • toxik4 hours ago
              So the future behavior is deprecated before it ever became the default?
              • nyrikki4 hours ago
                It was an abandoned path even before 3.10, it just took longer to implement 649 and 749 than they expected.<p>But this is a &quot;...will continue to exist with its current behavior <i>at least</i>...&quot; is an important bit there.<p>From pep-0749:<p><pre><code> Sometime after the last release that did not support PEP 649 semantics (expected to be 3.13) reaches its end-of-life, from __future__ import annotations is deprecated. Compiling any code that uses the future import will emit a DeprecationWarning. This will happen no sooner than the first release after Python 3.13 reaches its end-of-life, but the community may decide to wait longer. </code></pre> It has a good overview of the history.<p><a href="https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0749&#x2F;" rel="nofollow">https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0749&#x2F;</a>
              • js24 hours ago
                Correct. Before the &quot;from __future__ import annotations&quot; behavior that converts annotations to strings became the default, they figured out a better mechanism for circular type annotations (making them lazy) that is implicitly backwards compatible and that didn&#x27;t need to be guarded behind a future statement.<p>Ironically, the new default behavior (making type annotation evaluation lazy) is <i>not</i> backwards compatible with the &quot;from __future__ import annotations&quot; behavior of converting annotations to strings, so they can&#x27;t just rip out &quot;from __future__ import annotations&quot; and instead it needs to be deprecated and removed over multiple releases.<p>Oh, what tangled webs we weave! :-)
      • athorax6 hours ago
        [dead]
    • karpetrosyan8 hours ago
      Note that you can work around it by implementing `def __getattr__(name: str) -&gt; object:` at the module level on earlier Python versions
      • saghm7 hours ago
        Somehow I have no trouble imagining this being used as a rationale to avoid unnecessary &quot;magic&quot; to the language for years
      • wrmsr6 hours ago
        [dead]
    • boxed9 hours ago
      Yes, 3.15+
    • alcazar5 hours ago
      [dead]
    • rad1208 hours ago
      Python is such a weird language. Lazy imports are a bandaid for AI code base monstrosities with 1000 imports (1% of which are probably Shai Hulud now).<p>And now even type imports are apparently so slow that you have to disable them if unused during the normal untyped execution.<p>If Instagram or others wants a professional language, they should switch to Go or PHP instead of shoehorning strange features into a language that wasn&#x27;t built for their use cases.
      • stingraycharles8 hours ago
        &gt; Python is such a weird language. Lazy imports are a bandaid for AI code base monstrosities with 1000 imports<p>Just because you don’t like a feature doesn’t mean it’s because of AI and bad code.
        • sigmoid108 hours ago
          I think this is just a natural consequence of an easy-to-use package system. The exact same story as with node. If you don&#x27;t want lots of imports, don&#x27;t make it so damn easy to pile them into projects. I&#x27;m frankly surprised we still see so few supply chain attacks, even though they picked up their cadence dramatically.
          • saghm7 hours ago
            This seems a lot more due to an import running arbitrary code because stuff can happen in the top-level of a module rather than only happening in functions. From what I can tell, it seems pretty common for dynamically typed languages and pretty much entirely absent from statically typed ones, which tend to have a main function that everything else happens inside transitively. I guess this makes it easy if what you&#x27;re writing is something that runs with no dependencies, but it&#x27;s a pretty terrible experience as soon as you try to introduce the concept of a library.
            • kokada7 hours ago
              &gt; it seems pretty common for dynamically typed languages and pretty much entirely absent from statically typed ones<p>Counter-example is Go and init() function.
              • saghm7 hours ago
                Interesting, I had no idea that existed! I still think there&#x27;s a a difference between &quot;here&#x27;s a hook you can use to run stuff earlier&quot; and &quot;importing any module is fundamentally the same as running it as a script unless the module happens to use a special conditional to wrap stuff inside of&quot; though (and I say this as someone who doesn&#x27;t go out of his way to defend Go design decisions)
              • lanstin2 hours ago
                Static initializers in C++ - sometime ago I saw savings of some 400 ms (?) startup cost of initializing static strings from constants by moving it to some compile time thing.
                • saghm1 hour ago
                  Right; the issue is that this isn&#x27;t happening at compile time in Python, because it&#x27;s not getting compiled ahead-of-time. The equivalent would be if header files had imperative code that got executed at <i>runtime</i> in places where they&#x27;re included.<p>(To preempt potential pedantry: yes, I know that you can compile Python to bytecode ahead of time, but that&#x27;s not really relevant to what&#x27;s being discussed here because it doesn&#x27;t mean &quot;the stuff happening in modules I import isn&#x27;t happening at runtime anymore&quot;)
              • assbuttbuttass5 hours ago
                Also C++&#x2F;Java static initialization, C# static constructors, or Rust global variable initialization, ...<p>Most languages have this feature Afaik
                • ameliaquining2 hours ago
                  Rust doesn&#x27;t have this behavior (sometimes called &quot;life before main&quot;). Code to initialize a static variable runs either at compile time, or lazily on first access, depending on which mechanism you use.
          • ameliaquining2 hours ago
            IIUC the organizations that most strongly pushed for this feature are big companies with large codebases. These tend not to be the kinds of orgs that just casually pull in dependencies from PyPI on a whim; I think it more likely that the quantity of <i>first-party</i> code was so large that importing all of it on startup was causing problems.
          • stevesimmons7 hours ago
            What would your alternative look like?
        • xtajv6 hours ago
          Too much syntactic sugar causes cancer of the semicolon.
        • tremon6 hours ago
          True, but this is yet another code path that isn&#x27;t exercised until specific conditions happen. That means even more latent application behaviour can go undetected by unit testing and security profiling until the moon is in the right phase, which is a boon for submarine attacks.
      • novov8 hours ago
        Empirically, I have used the current accepted way to do lazy imports (import statement inside a function) before AI coding was even a mainstream thing, for personal code that sometimes needs a heavy import and sometimes doesn’t.<p>The lazy statement would be an improvement as it allows one to see all the imports at the top where you expect them to be.
        • afH128 hours ago
          As a now deleted comment pointed out, lazy imports had been requested forever. They were rejected forever and were accepted <i>just when BigCorps wanted them</i>.<p>Python-dev now is paid to shore up the failed Instagram stack.
          • zem4 hours ago
            both lazy imports and free threading have been proposed ages ago, they both went through several iterations before a good design was settled upon and made it into the language.<p>in the case of lazy imports the big corps were the ones doing the experimentation and iteration. the feature didn&#x27;t make it into the language &quot;just when big corps wanted them&quot;; the instagram stack you allude to already had its own fork of cpython with lazy imports added years ago, and that is <i>not</i> the design that ended up getting adopted by upstream cpython, though some of the people working on it also collaborated on the PEP that finally did make it in.
          • brookst8 hours ago
            I too am outraged that a product would prioritize its biggest users.
            • saghm7 hours ago
              Is the biggest user larger than the combined set of individual users who had asked for (or would benefit from) the same thing? I honestly don&#x27;t know, but I don&#x27;t think that things are always as simple as you&#x27;re implying in a world where we have the collective action problem.
              • brookst7 hours ago
                If you’re asking some some kind of abstract moral value sense, I have idea.<p>If you’re asking whether project leads give more weight to a single, tangible, vocal stakeholder than they do to unknown numbers of anonymous and lightly-engaged stakeholders? Yes.
                • WorldMaker5 hours ago
                  Not to mention when the single, tangible, vocal stakeholder can also be asked to be responsible for documentation (PEPs, etc) and PRs. Especially in open source there is a huge difference between &quot;a lot of people asked about this&quot; and &quot;one person asked about this, but was passionate enough about it and open enough to following the process and the feedback loops to champion it all the way across the finish line&quot;.
                  • saghm4 hours ago
                    I don&#x27;t have any issue with what you&#x27;re saying if that&#x27;s what happened. There&#x27;s quite a gap between that sort of reasoned explanation and treating concerns about large stakeholders versus large numbers of small one with derision.
                    • WorldMaker3 hours ago
                      For what it is worth, I was trying not to make a value judgment on it, especially not with relation to this specific instance, I was hopefully just recognizing it as a motivating factor in general open source politics. Sometimes that <i>is</i> quite regretful because it is anti-democratic and <i>does</i> look like favoritism or worse cronyism when it plays out in that way of &quot;we listened to the person&#x2F;company that built and tested a prototype and did all the work to standardize and then PR it over the many developers that wanted an idea but didn&#x27;t have the time&#x2F;money&#x2F;bandwidth to implement it themselves&quot;.
                      • saghm1 hour ago
                        That&#x27;s fair. I think I mostly reacted because of the sarcastic faux-outrage that the original comment I responded to expressed. These are hard problems, and I think the presumption should be someone being frustrated at the slow state of changes they want probably has legitimate reasons to feel that way, just as the presumption should be that open-source projects that have run successfully for a long time probably are making good-faith effort to steward what they&#x27;re maintain. Acknowledging the tension between priorities not lining up exactly for everyone and not having knee-jerk reactions when someone is unhappy seems preferable to mocking those who you disagree with.
                • saghm7 hours ago
                  I mean, yes, demonstrably, the phenomenon you&#x27;re describing happens. Your previous comment seems pretty sarcastically dismissing the idea that someone could disagree with this being a good thing though, and I was making a counterargument against the underlying opinion that seemed apparent.
          • Daishiman5 hours ago
            It was accepted just as multiple large corporations with competent teams of internal tool departments ended up forking the interpreter to support lazy imports and demonstrated empirically that the idea has merit.
      • formerly_proven8 hours ago
        On most unix-likes all &quot;imports&quot; via shared libraries (e.g. in C &#x2F; C++) are lazy by default.
  • kwon-young6 hours ago
    It&#x27;s nice that python 3.15 added Iterator synchronization primitives: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3.15&#x2F;library&#x2F;threading.html#iterator-synchronization" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3.15&#x2F;library&#x2F;threading.html#iterator...</a>. These will nicely complement my threaded-generator package which is doing just this but using a thread&#x2F;process+generator+queue: <a href="https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;threaded-generator&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;threaded-generator&#x2F;</a>
  • JohnKemeny8 hours ago
    &gt; <i>I&#x27;ve left this one to the bonus section because I&#x27;ve never used set operations on Counters and I&#x27;m finding it extremely hard to think of a use case for xor specifically. But I do appreciate the devs adding it for completeness.</i><p>Check out <i>symmetric difference</i><p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Symmetric_difference" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Symmetric_difference</a>
    • qsort7 hours ago
      Yeah, but applied to counters it would be the symmetric difference between multisets, which doesn&#x27;t have a natural definition. If I understood the proposal they&#x27;d be defining it as absolute value of the difference of the counts, which isn&#x27;t even associative.<p>If they only considered parities it could be interpreted as addition in F_2, which is more natural, but I&#x27;d still agree that it&#x27;s hard to see how you&#x27;d use something like this in practice.
      • gtheodor5 minutes ago
        You can get the L_k distances between the two counters. E.g. if you sum the absolute value of the difference of the counts, you get the L_1 distance between the counters. If you raise them to the n^th power and then sum them, you get the L_n distance. For n=2, that&#x27;s the Euclidean distance (squared).
  • xg153 hours ago
    &gt; <i>Iterators, async functions and async iterators don&#x27;t work well here because they have different semantics to standard functions. When you call them they return immediately with a generator object, coroutine function and async generator object respectively. So the decorator completes immediately as opposed to the entire lifecycle what it&#x27;s wrapping.</i><p>&gt; <i>This is an unfortunate problem I&#x27;ve encountered many times, and it&#x27;s often a problem for normal decorators too. But this has changed in 3.15, now the ContextDecorator will check the type of the function it&#x27;s wrapping and ensure that the decorator covers the entire lifespan.</i><p>I very much like the idea of that change - but it also seems kind of dangerous, to do this with no &quot;opt-in mechanism&quot;, as that quite subtly changes the behavior of existing usage sites.<p>This is a bit of a &quot;spacebar heating&quot; situation, because someone would have to intentionally use a decorator in the old, broken way, but if someone actually did that, things may unexpectedly break.
    • ameliaquining2 hours ago
      The Python core team seems to think it&#x27;s unlikely that anyone&#x27;s relying on the existing behavior: <a href="https:&#x2F;&#x2F;github.com&#x2F;python&#x2F;cpython&#x2F;pull&#x2F;136212#issuecomment-4332309019" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;python&#x2F;cpython&#x2F;pull&#x2F;136212#issuecomment-4...</a>
      • xg152 hours ago
        Ok, good to see that they checked that possibility. Looks like there was no situation in which the previous behavior could have been usable, so yeah, agreeing with the change then.
    • Drakim2 hours ago
      Eh, what&#x27;s the worst that could happen? Developers opting to run an old version of Python due to incompatible changes? I can&#x27;t see that happening.
  • veqq5 hours ago
    There&#x27;s a good interview about Python internals and management, particularly in relation to free-threading: <a href="https:&#x2F;&#x2F;alexalejandre.com&#x2F;programming&#x2F;interview-with-ngoldbaum&#x2F;" rel="nofollow">https:&#x2F;&#x2F;alexalejandre.com&#x2F;programming&#x2F;interview-with-ngoldba...</a>
  • drchaim4 hours ago
    Oh, my beloved Python, for nearly 15 years I wrote you. I miss you, but I no longer do — it&#x27;s not your fault, life has changed.
  • jwineinger3 hours ago
    One of the Counter examples is incorrect, tested on both 3.13 and 3.15.0a<p><pre><code> &gt;&gt;&gt; from collections import Counter &gt;&gt;&gt; c = Counter(a=3, b=1) &gt;&gt;&gt; d = Counter(a=1, b=2) &gt;&gt;&gt; c-d Counter({&#x27;a&#x27;: 2})</code></pre>
  • brianwawok9 hours ago
    I was so into Python for 10 years, was enjoyable to work in. But have deleted 100k+ lines this year already moving them to faster languages in a post AI codebot world. Mostly moving to go these days.
    • stuaxo8 hours ago
      This is straightforward in the first instance, but how do you see maintenance of those projects going forward - especially adding more complex features ?<p>I can see one way forward being to prototype them in python and convert.
    • sinpif7 hours ago
      I&#x27;m still on the lookout for a comprehensive Django-like web framework for go. That would be an instant hit for me.
      • seabrookmx2 hours ago
        Try another language? The Go ecosystem tends towards libraries as opposed to &quot;frameworks.&quot;<p>I personally chose C# for this reason, because ASP.NET is mature and (IMO) well designed. But there&#x27;s also Java&#x2F;Spring and and lots of other options in different languages depending on your preferences.
      • pennomi6 hours ago
        Same here. Django is my last holdout for Python. Everything new is go.
    • BOOSTERHIDROGEN8 hours ago
      Interested in why you&#x27;d use Python in the first place? Advice for someone who knows nothing about programming - what would you suggest?
      • js24 hours ago
        Programs have to run in a lot of different contexts, not just as servers, and for some of those contexts (especially say glueing together other programs), an interpreted language is more convenient and easier to work with. In fact, unless I care about performance, I&#x27;m going to use an interpreted language because having the source close at hand when something breaks just turns out to be super useful.
      • t435623 hours ago
        Because it&#x27;s quick and easy to radically alter and refactor your prototype as you learn the problem space. By the time it works you often find out that you don&#x27;t need anything more. This is something that Perl had.<p>Once your program starts to get bigger you have abstractions that can cope fairly well and keep your code simple to use - this is what Perl didn&#x27;t have.<p>If you need more speed then you can write extensions in some compiled language.I think TCL was better at this hybrid approach but Python is a nicer language in itself.<p>You can also just dump python and write everything in that other language but now you understand the problem space quite well and you won&#x27;t be trying to learn about it using a language where change is &quot;difficult.&quot;
      • IshKebab7 hours ago
        IMO the main reasons people use Python are:<p>1. The very first steps are quite simple. Hello world is literally just `print(&quot;hello world&quot;)`. In other languages it can be a lot more complex.<p>2. It got a reputation as a beginner-friendly language as a result.<p>3. It has a &quot;REPL&quot; which means you can type code into a prompt and it will execute it interactively. This is very helpful for research (think AI) where you&#x27;re trying stuff out and want to plot graphs and so on.<p>IMO it is undeservedly popular, or at least was. Wind back 10 years to when it was rapidly gaining mindshare:<p>1. While &quot;hello world&quot; is simple, if you went further to more complex programs you would hit two roadblocks: a) the lack of static type checking means large programs are difficult to maintain, and b) it&#x27;s really really slow.<p>2. While the language is reasonable, the tooling (how you install packages, manage the code and so on) was eye-bleedingly abysmal.<p>3. While the REPL did technically exist, it was really bare bones. It couldn&#x27;t even handle things like pasting code into it if the code contained blank lines (which it usually does).<p>However since it has become arguably the most popular language in the world, a lot of people have been forced to use it and so it is actually getting quite decent now. It has decent static types (even if lots of people still don&#x27;t use them), the REPL is actually decent now (this changed <i>very</i> recently), and there&#x27;s a new third party tool called `uv` to manage your code that is actually good.<p>The biggest issue with it now is that it&#x27;s still horrifically slow (around 50-200x slower than &quot;fast&quot; languages like C++, Rust etc). It is pretty unlikely that that will ever change. People always try to excuse this by saying Python is a &quot;glue&quot; language and you just use it to connect components written in faster languages, but a) that&#x27;s pure &quot;you&#x27;re holding it wrong&quot;, and b) that only works in some cases where there are nicely separated &quot;slow bits&quot; that can be moved to another language. That&#x27;s the case for AI for example, where it&#x27;s all numerical, but for lots of things it isn&#x27;t. Mercurial was a competitor to Git that was written in Python and lost partly because it was way too slow. They&#x27;ve started writing parts in Rust but it took them 10 years to even start doing that and by then it was far too late.<p>&gt; what would you suggest?<p>It really depends on what you want to make. I would pick something to make first and then pick the language based on that. Something like:<p>* AI: Python for sure. Make sure you use uv and Pyright.<p>* Web-based games: Typescript<p>* Web sites: Typescript, or maybe Go.<p>* Desktop GUI: Tbh I&#x27;d still use C++ with QtWidgets. Getting a bit old-school now tbf.<p>Also Rust is the best language of them all, but I dunno if I&#x27;d pick it as a beginner unless you really know you want to get into programming.
        • 1_08iu5 hours ago
          I think &quot;Python is slow&quot; is reductive and frankly just as useful as saying &quot;Python begins with a &#x27;P&#x27;&quot;. The story is more complicated than simply speed of execution.<p>Choosing a language is a game of trade-offs: potentially slower execution in return for faster development time, for example. If your team is already familiar with Ruby, will asking them to write a project in Rust necessarily result in a better product? Maybe, but it will almost certainly take much longer.<p>Anyway, how many Python programs are actually &quot;too slow&quot;? Most of the time, Python is fast enough, even if heavy computation is offloaded to other languages.<p>As for Rust being the best language of them all, that&#x27;s, like, your opinion, man.
          • rirze3 hours ago
            I agree with you; I&#x27;ve developed in Python for most of my career and a lot of Python criticism is malformed.<p>That being said, I&#x27;m starting all new large development work in Rust. Python is hard to reason about due to its dynamic nature in large codebases. And if I&#x27;m enabling strict typing everywhere, I might as well use a typed language and get a performance boost. Obviously, this is only because I&#x27;m the sole developer and using AI to improve productivity.<p>Work settings are completely different and one has to be a team player to find the language that works for everyone.
          • IshKebab1 hour ago
            &gt; potentially slower execution in return for faster development time, for example.<p>Another classic lie about Python. The slower speed doesn&#x27;t matter because it&#x27;s development speed that&#x27;s important, and Python gives you faster development speed!<p>Except... it absolutely doesn&#x27;t. It would be very difficult to argue that Typescript has significantly slower development speed but it is <i>much</i> faster to execute. I also disagree that Python is any faster than Go, Rust or Lotion, but I think lots of people blindly accept that it is and would argue based on that.
          • altmanaltman4 hours ago
            [dead]
        • mixmastamyk5 hours ago
          ptpython has existed for a decade, maybe two, and python is high level, more readable than most languages. Exec speed hasn’t mattered in my near thirty years of using it for business and prototyping tasks which it promoted early.<p>Yes it strains at the big to huge project end, not recommended to take it there. Still there are better tools to help now.
        • markdown2 hours ago
          &gt; * Web sites: Typescript, or maybe Go.<p>lol, no. Just no. Python is far superior for website backends unless perhaps you&#x27;re running one of the top 20 websites in the world.
    • physicsguy9 hours ago
      Go is terrible for scientific&#x2F;ML work though, the libraries just aren&#x27;t there. The wrapping C API story is weak too even with LLMs to assist.<p>Try and write a signal processing thing with filters, windowing, overlap, etc. - there&#x27;s no easy way to do it at all with the libraries that exist.
      • LtWorf9 hours ago
        I think the purpose of go is to write CRUD. Stray from that and you&#x27;re on your own.
        • zem3 hours ago
          crud is a pretty poor fit for go, you&#x27;re better served by languages like python that can autogenerate classes that reflect the db schema. go&#x27;s sweet spot is things like network servers.
          • mywittyname20 minutes ago
            Go tooling has this kind of thing as well. I&#x27;m not a huge fan of go, but last time I had to work with it, we leveraged a lot of codegen.
          • luckydata3 hours ago
            you just need the right tools <a href="https:&#x2F;&#x2F;github.com&#x2F;CaliLuke&#x2F;loom" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;CaliLuke&#x2F;loom</a>
    • deppep8 hours ago
      i don’t really see it this way. the value of a token in Python is much higher than it is in lower-level language
    • shankysingh9 hours ago
      Thats very intersting, If I may ask was it from professional projects or personal projects?
    • mountainriver9 hours ago
      Same, I’m not sure how Python survives this outside of machine learning.<p>All of our services we were our are significantly faster and more reliable. We used Rust, it wasn’t hard to do
      • prodigycorp9 hours ago
        the funny thing is that everyone, including myself, posited that python would be the <i>winner</i> of the ai coding wars, because of how much training data there is for it. My experience has been the opposite.
        • tyre8 hours ago
          I felt the opposite, because Python isn’t a great language. It won because of Google, fast prototyping, and its ML interop (e.g. pandas, numpy), but as a language it’s always been subpar.<p>Indentation is a horrible decision (there’s a reason no other language went this way), which led to simple concepts like blocks&#x2F;lambdas having pretty wild constraints (only one line??)<p>Type decoration has been a welcome addition, but too slowly iterated on and the native implementations (mypy) are horribly slow at any meaningful size.<p>Concurrency was never good and its GIL+FFI story has boxed it into a long-term pit of sadness.<p>I’ve used it for years, but I’m happy to see it go. It didn’t win because it was the best language.
          • Sohcahtoa824 hours ago
            &gt; lambdas having pretty wild constraints (only one line??)<p>I will never understand why people are upset about this.<p>You HAVE multi-line lambdas. They&#x27;re called functions.<p>Yeah, I know you want a function that&#x27;s only used once to be able to be defined in-line, but tbh I&#x27;ve always found that syntax to be pretty ugly, especially once you&#x27;re passing two functions to a single call, or have additional parameters AFTER the function (I&#x27;m looking at you, setTimeout&#x2F;setInterval).
          • zabzonk8 hours ago
            &gt; there’s a reason no other language went this way)<p>Except of course for those that did, Haskell, Fortran for example.
            • bonesss5 hours ago
              F# as well, and that tends to exist in parallel with some degree of C# written by the same devs… the indentation enables cleaner, smaller, simpler code function by function.<p>It’s pretty ok in Python, but meaningful indentation is <i>amazing</i> with a proper type system and compiler. Clean, consistent, efficient, and ensures working code is easily read and standardized.<p>I’m unaware of anyone accepting improperly formatted C# as ‘done’, and would reject any such PR out of hand because of the potential for legibility issues to hide bugs. So: if it were done when &#x27;tis done, then &#x27;twere well it were done by the compiler to save line noise.
          • groundzeros20158 hours ago
            I’m always baffled when language complaints come down to syntax
            • Ringz5 hours ago
              That’s exactly how I think, too. But at the same time, I like indentation in Python, because I would logically indent in every other language as well. In fact, I find all those semicolons and similar things at the end of each line completely redundant (why should I repeat myself for something the compiler should do) and I hate them. And that’s despite having experience with Modula and 10 years of C++. But when I look at Rust, I find the syntax simply awful. From an ADHD perspective…
          • smallerize6 hours ago
            Lambdas are intentionally kneecapped in python because Guido van Robson doesn&#x27;t want to make a functional language. (As in &quot;functional programming&quot;, not that it doesn&#x27;t work.)
            • ciupicri6 hours ago
              Guido van Rossum didn&#x27;t oppose functional programming, but he wanted to keep the language (and the interpreter) simple.
              • smallerize4 hours ago
                &quot;I didn&#x27;t envision Python as a functional language&quot; <a href="https:&#x2F;&#x2F;python-history.blogspot.com&#x2F;2009&#x2F;04&#x2F;origins-of-pythons-functional-features.html" rel="nofollow">https:&#x2F;&#x2F;python-history.blogspot.com&#x2F;2009&#x2F;04&#x2F;origins-of-pytho...</a><p>&quot;I don&#x27;t think it makes much sense to try to add &quot;functional&quot; primitives to Python, because the reason those primitives work well in functional languages don&#x27;t apply to Python, and they make the code pretty unreadable for people who aren&#x27;t used to functional languages (which means most programmers). I also don&#x27;t think that the current crop of functional languages is ready for mainstream.&quot; <a href="https:&#x2F;&#x2F;developers.slashdot.org&#x2F;story&#x2F;13&#x2F;08&#x2F;25&#x2F;2115204&#x2F;interviews-guido-van-rossum-answers-your-questions" rel="nofollow">https:&#x2F;&#x2F;developers.slashdot.org&#x2F;story&#x2F;13&#x2F;08&#x2F;25&#x2F;2115204&#x2F;inter...</a>
        • rplnt8 hours ago
          AI benefits from tools to verify its halucinations. That&#x27;s much easier in a typed and compiled language. Then have a language that can&#x27;t be monkey patched at runtime and the confidence increases even more.<p>If you mean &quot;easy to get something out of it&quot; then yeah, it&#x27;s great.
        • za3faran1 hour ago
          I wouldn&#x27;t be surprised if static typing had something to do with it.
        • dkersten7 hours ago
          Typescript wins in terms of training data IMHO, by which I mean that the training data is large enough that AI does great with TS, and the language is (IMHO) superior to Python in many ways.<p>I personally now use a mixture of Typescript and Rust for most things, including AI coding. Its been working quite well. (AI doesn&#x27;t handle Rust as well as TS, in that the code isn&#x27;t quite idiomatic, but it does ok)
          • CuriouslyC7 hours ago
            It turns out that volume of training data isn&#x27;t the most important thing. Elixir beats Kotlin and C#, which beat pretty much everything else. Kotlin is probably the sweet spot for most things.
            • dkersten5 hours ago
              Not the most important thing, but it certainly helps.
        • lexicality8 hours ago
          a lot of the training data is either for python 2 or just generally very low quality
          • stuaxo8 hours ago
            The quality issue doesn&#x27;t seem unique to Python.<p>The versioning issue I&#x27;ve seen across libraries that version change in many languages.<p>I don&#x27;t tend to hit Python 2 issues using LLMs with it, but I do hit library things (e.g. Pydantic likes to make changes between libraries - or loads of the libraries used a lot by AI companies).
            • bigfudge7 hours ago
              I’ve found recent Claude to be much better in this regard. I think a lot rests on the quality of the harness and the work behind the scenes done to RAG up to date docs or search for docs proactively rather than guessing.<p>I also don’t have issues with quality of Python generated. It takes a bit of nudging to use list comps and generators rather than imperative forms but it tends to mimic code already in context. So if the codebase is ok, it does do better.
          • prodigycorp8 hours ago
            That could be it. I still see LLMs fail a set of static typing challenges that I created a couple years ago as a benchmark. Google models still fail it. I wonder if the lack of typing in a lot of the training data makes python harder to reason about?
        • lsbehe8 hours ago
          The tons of python code would be great training data if there was any consistency across the ecosystem. Yet every project I&#x27;ve touched required me to learn it&#x27;s unique style. Then I&#x27;d imagine they practically poisoned half the training set because python2 is subtly different.
      • LtWorf9 hours ago
        You can test on the device directly, without needing to recompile to try something.
    • zabzonk8 hours ago
      Three things I find unlikely about this:<p>- You wrote 100K lines of code (I&#x27;ve worked on several large C++ projects that were far smaller)<p>- You wrote those lines in Python (surely the whole point of Python is to write less code)<p>- You deleted them (never delete anything, isn&#x27;t this what modern VCS is all about?)<p>But whatever floats your boat.
      • dkersten7 hours ago
        &gt; You deleted them (never delete anything, isn&#x27;t this what modern VCS is all about?)<p>The person said: &quot;deleted 100k+ lines this year already moving them to faster languages&quot;<p>Are you saying that when you move code to another language&#x2F;rewrite in another language, you leave the original languages code in your repo?<p>They didn&#x27;t say they deleted it from their git history. I delete code all the time (doesn&#x27;t mean its &quot;gone&quot;, just that its not in my git head).
        • zabzonk7 hours ago
          Well, they deleted it from somewhere. As I assumed they were using a VCS I assumed they deleted it from that. Or are they really short of disk space?
          • dkersten5 hours ago
            Deleted from the current head&#x2F;trunk of the repo, ie the deployed code.<p>Deleting &quot;from my codebase&quot; doesn&#x27;t imply deleting it from history or backups. Just that the code isn&#x27;t present for future edits or deployments.<p>The way you&#x27;re talking, it sounds like you never delete code from your codebase. Do you just comment it out when you change a line to something else or replace a function with a new one? Just add new files?
          • rcxdude6 hours ago
            In this context I would assume deleting code to mean deleting it from the current version of the software, not removing from the VCS history entirely.
      • throwatdem123117 hours ago
        100k lines is tiny what are you on about, especially in the monolithic app sass world where many Fyll stack apps that handle all business ops are probably written with Django.<p>Our entire business runs on 300k lines of Ruby (on Rails) and I can keep most of the business logic in my head. I would say our codebase is not exactly “tiny” and just cracking the ceiling into “smal” territory. And comparatively, people probably write even <i>less</i> code in equivalent rails apps to django ones. 100k lines of C++ is <i>miniscule</i>.<p>Obviously “deleting code” in this context doesn’t mean purging version control history but the current state of the codebase.
        • zabzonk7 hours ago
          &gt; 100k lines is tiny<p>No, no, it is not, or at least not in my experience (I do not and never have done web development - medium performance C++ code - I don&#x27;t see how I could write, understand and support 100K lines of code in this area).<p>And so, what does your Ruby code actually do?
          • 63stack35 minutes ago
            100k lines is huge, I don&#x27;t know what these jokers are on
          • rcxdude7 hours ago
            Your experience doesn&#x27;t match mine. I have, mostly solo, and part time, written multiple codebases that on that kind of magnitude (it is about the level where it still will fit in one person&#x27;s head pretty easily IMO). It doesn&#x27;t take much to reach that kind of size. Now, if all of it was super dense and subtle code, then yeah, that would be a lot, but in my experience that&#x27;s usually a pretty small part of any given codebase.
            • zabzonk6 hours ago
              &gt; in my experience that&#x27;s usually a pretty small part of any given codebase<p>Our experiences differ then. Mine is that almost all of the code I write is directly targeted on the usually quite complex problem I am trying to solve. I don&#x27;t do boilerplate, for example.
              • rcxdude6 hours ago
                I tend not to have much boilerplate (and write abstractions to avoid it), but I do still find there tends to be a lot of supporting code around the &#x27;difficult bits&#x27; (TBH, most of the code I write is supporting a small amount of relatively simple but subtle operations, but such is the nature of embedded software). But different codebases are quite different in this regard: this is why such different scales shouldn&#x27;t be too surprising in different domains.
      • squirrellous7 hours ago
        Uhm what? All of those things are totally ordinary.
        • zabzonk7 hours ago
          &gt; All of those things are totally ordinary. reply<p>I would need some evidence of that.
  • vorsken13 minutes ago
    The `except*` improvements are underrated. Been using ExceptionGroup in a CLI tool that wraps Semgrep — catching multiple subprocess errors cleanly in one block made the retry logic much simpler.
  • BiteCode_dev1 hour ago
    Note that 3.15 is not released yet. It will come out in 4 months
  • aniou2 hours ago
    I come to Python around version 1.5, painfully tired by debugging CGI scripts, created by wannabe perl-golfers. Unfortunately, I feel like Python is losing more and more of the zen that once tempted me...<p>Lazy loading looks like a last nail in the coffin, where my love to Python was buried, although it was a long, tiresome process.
  • syedMohib454 hours ago
    Thread safe ittertors? really are we still on these topics<p>lazy from typing import Iterator<p>def stream_events(...) -&gt; Iterator[str]: while True: yield blocking_get_event(...)<p>events = stream_events(...)<p>for event in events: consume(event)
  • sunshine-o7 hours ago
    I am not a python dev but have the utmost respect for the ecosystem.<p>But damn, with all the supply chain attacks now in the news, could they just make a simple way (for non python insiders) to install python apps without fearing to be infected by a vermin with full access to my $HOME ...
    • nyrikki4 hours ago
      There is no security barrier at all in UNIX(-like) Os&#x27;s between a caller&#x2F;callee, this is not thing that python can just fix.<p>There are ways to harden and&#x2F;or reduce privileges, but shells&#x2F;scripting languages will always have this issue on any modern OS.<p>The UNIX way to help prevent that is really to run processes as another user, but people seem to refuse to do so. You should <i>always</i> expect any process running as your UID to be able to access any data owned or visible to your UID.<p>While it is possible to reduce the risk of disclosure, they are all wack-a-mole preventions protecting the low hanging fruit, not absolute guarantees.<p>That is purely due to how UNIX works [0]<p>[0] <a href="https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man7&#x2F;credentials.7.html" rel="nofollow">https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man7&#x2F;credentials.7.html</a>
    • surajrmal6 hours ago
      There is little that they can do short of running the programs in a VM. Linux distros aren&#x27;t engineered to consider applications as something different from the user running them. You need a completely different security model to achieve that and the Python runtime isn&#x27;t tackle that.
      • sunshine-o5 hours ago
        In its inception 35 years ago the creator of python could not foresee how far python would go and how the environment would look like today. But nowadays there are a lot of security mechanisms they could leverage to adapt (from chroot by default to namespaces, cgroup, etc. on Linux, pledge, unveil on OpenBSD).<p>The very idea that you offer a (python) package installer that is gonna pull a tree of code published and updated by random people in an unvetted manner open the door to all the supply chain attacks we are seeing.<p>Around the same time (early 90s) Java was designed with high isolation in mind but the goal and vision was very different. And Java had its own problems.<p>I&#x27;m saying that because at some point the security problem is gonna really hurt the python ecosystem.
  • armanj7 hours ago
    funny how we may have to wait even longer for llms to pick up this update in their pre-training
    • Alifatisk4 hours ago
      Is there seriously no solution to this? Perhaps something we fan do post training? For example add the new features to SKILLS.md? But the trade-off here is of course tokens.
      • shankysingh23 minutes ago
        My working methodology has been , LLM output is a jumping point and to use my experience, knowledge and basic understanding to N+1 it.<p>So for bleeding edge stuff it works out well or in places where documentation is not great like Apache Flink.