Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    David Beazley
    @dabeaz
    Hello. Use this channel to ask me anything!
    Horacio Hoyos
    @arcanefoam
    Hello David, I follow you on twitter and find your tweets very interesting. Thanks for opening a direct communication channel.
    Rohit Sanjay
    @rohitsanj
    Hi David! We'd met in Chennai during PyCon India 2019 :)
    David Beazley
    @dabeaz
    Hi Rohit, nice to meet you again here.
    Stephen Harding
    @stharding
    Hi Dave, I did a compilers class with you. Thanks for opening this forum!
    Domingo gomez
    @GomezDominus_twitter
    Hi, David
    My sister joined the compiler class and it was really good. You use LLVMLite to generate code
    for a language that you call Be Gone. However, there you didn't use Pointers so, do you have a small example on how to fill pointers?
    David Beazley
    @dabeaz
    I'm not sure I have an example of pointers in LLVMLite. However, the API to llvmlite is meant to closely mimic the C/C++ API to LLVM. So, you might be able to adapt a pointer example from LLVM without making a lot of changes.
    Domingo gomez
    @GomezDominus_twitter
    Thanks! I will try to take a look. Another question, I am joining the course Structure and Interpretation of Computer Programs. Should I buy the book in advance and read it?
    David Beazley
    @dabeaz
    The SICP book can be found online for free from the publisher. So, no need to buy it unless you really want to have a hard copy. As for reading it in advance--most people find it to be a pretty challenging read (including myself). The whole point of the course is to work through the book, so I'd say it's not necessary to read it advance. You could certainly skim it. Maybe work a few exercises at the beginning. But, it's not really necessary to do much beyond that.
    Sandeep Gupta
    @skgBanga_twitter

    @dabeaz I noticed that one can't create issues related to curio now, so i am wondering if this is a good way of asking some basic questions about curio. (Please redirect me somewhere else if you think that is the case).

    In one issue on curio (https://github.com/dabeaz/curio/issues/270#issuecomment-405030942)

    you pointed out that there is something called await schedule(). I couldn't find it in the latest curio (1.4). I am wondering if it was removed, and if yes, is there any specific reason why it was removed?

    Please note that my curiosity is not completely academic. C++ is introducing co-routines in its next version, and has this https://en.cppreference.com/w/cpp/coroutine/suspend_always

    I was wondering what is the curio equivalent of this?

    David Beazley
    @dabeaz
    The curio issue tracker is temporarily disabled to stay out of Hacktoberfest. It will be back. Regarding schedule(). You can use await sleep(0) for this purpose.
    Sandeep Gupta
    @skgBanga_twitter

    Thanks for the reply.

    Right, that is listed in the issue. Considering you often draw parallels with OS scheduler which has https://linux.die.net/man/2/sched_yield, I was just wondering if there is any reason you removed it.

    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Hi Dave, I have attended "Advanced Python Programming" online sessions of your's. Thanks so much for opening up this forum. It helps a lot.
    David Beazley
    @dabeaz
    @skgBanga_twitter I feel that Curio is better served by be smaller and having a smaller API. A lot of things got removed in the transition to v1.0, this being one of them. Part of why it got removed is that it was already a one-line function that called await sleep(0). The other reason is that forcefully causing a context switch isn't something that seems to be required all that often. Also, if someone wanted to call it schedule(), they could make their own one-line function with that name.
    Sandeep Gupta
    @skgBanga_twitter
    @dabeaz that's fair. thanks!
    SandeepSuryaprasad
    @SSuryaprasad_twitter

    Hi Dave,
    I have the following code.a = 'hello!'

    b = 'hello!'
    a is b
    False
    id(a)
    140428602876016
    id(b)
    140428602876208
    Why does python creates two different string objects in the above example. But when you do not have any special character it does not create two new string objects. >>> a = 'hello'
    b = 'hello'
    a is b
    True

    David Beazley
    @dabeaz
    The optimization for not creating a new string only applies to strings that are valid identifiers (i.e., valid variable names).
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Thanks Dave.
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    I am iterating over a list which has one million items in it and also I am iterating over a tuple which has one million items. When I measure the time taken by list and tuple, there is negligible difference. Some times lists are faster by few milli seconds and some times tuples! When I looked up in stack overflow, it says tuples are little bit faster than lists.
    David Beazley
    @dabeaz
    Tuples might be faster than lists for certain things (creation perhaps), but it's hard to see how there would be any difference at all for iteration given the similarity of implementation.
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Thanks for your reply Dave.
    Damian Shaw
    @damian_shaw_gitlab
    I am considering joining "Holiday of Compilers!". Is it in danger of filing up in the next week? I'm applying for a tuition reimbursement program my company offers but they require I apply for approval first before I sign up to the course, just submitted the paperwork and am informed it usually takes 5 days to decide on approving
    David Beazley
    @dabeaz
    You should register now. I don't require any payment at time of registration.
    David Beazley
    @dabeaz
    I hold spots all of the time for people waiting for approval. Register first. Then ask permission.
    George Fortunatov
    @qweeze
    Hi @dabeaz :)
    I enjoy watching your talks a lot!
    I was inspired by your experiments with generators and coroutines, and came up with a weird idea of making a function behave both like a normal function and like an async coroutine (kinda). So I thought I might share it here - https://github.com/qweeze/maybe_async
    It would be super cool if you could share your advice or any kind of feedback.
    Vitaliy Litvinov
    @vitalizzare_twitter
    Hi! I came here to say that the Function is a very nice and neat essay. I learned a lot of subtleties in a fairly short time. I like it. Thanks!
    David Beazley
    @dabeaz
    Glad you liked it! (although I was definitely in a strange mood when I recorded that ;-)
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Dave, I found that instance dictionaries occupy less memory than the normal dict! I have a point class with two instance variables "a" and "b" with values 1 and 2 respectively. When i checked the size of the instance dictionary (using getsizeof()), it came back with 104 bytes. I created a normal dictionary with same keys and values , this time when i checked the size of the dict, i got 232 bytes! Are instance dictionaries more memory efficient than normal dictionaries?
    David Beazley
    @dabeaz
    Yes! (You have a keen eye). See PEP 412. https://www.python.org/dev/peps/pep-0412/
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Okay.. Thanks Dave.
    cmoher3
    @cmoher3

    Went to pick up an item I won at auction today. As there are Covid delays everywhere, I always bring along something to read. Today it was O'reilly's Python Cookbook, which I had on my dash as I approached the gate keeper. Seeing the book he asked if it was any good. Me wearing a mask and he deaf and only able to read lips, hard to do when we are all wearing masks, I gave him my OK hand gesture. He then went on with a fairly long story of the different snake dishes he had eaten in Florida. I listened with interest until he had finished with the "Soupa Serpente" (Snake Soup) he had in Mexico and for him to ask if there were any favorite python recipes in my book. I finally pulled down my mask and mouthed "No, Computers" and mimicked me typing on a keyboard. He replied that he'd search the internet when he got home for recipes and waved me through.

    Have a Merry Christmas David and stay well.

    David Beazley
    @dabeaz
    This reminds me of the time I told the people in the restaurant I frequent across the street from my office that I wrote the "Python Cookbook." They were highly amused.
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Constructing a list using list constructor takes less memory than constructing the same list using append method! list(range(10000000)) takes (359992868, 359993060) and using append method it takes (361520804, 361520852) I used tracemalloc to measure the memory.
    David Beazley
    @dabeaz
    Many objects are able to give the list constructor a size hint about how many objects it will contain. Without this, append() tends to slightly overallocate memory since it grabs memory in increasingly large chunks as the list grows in size.
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Thanks Dave..
    SandeepSuryaprasad
    @SSuryaprasad_twitter
    Can we consider "ceval.c" as a python virtual machine since it is executing compiled byte code.
    Stephen Harding
    @stharding
    Dave, any plans to post any more video series to oreilly?
    David Beazley
    @dabeaz
    No plans for videos at this time.
    Kamil
    @UltraInstinctPL_twitter
    Hey Dave, what about 4th edition of Python Cookbook? Any plans?
    David Beazley
    @dabeaz
    It's extremely unlikely that there will be a 4th Edition Cookbook. Not my me anyways. Sorry.
    Christian W.
    @cew8
    I think I sort of answered my own question. Removing.
    Shivam Vikal
    @sunkgp
    Hi David,
    Chapter 10 - Execution Environment: "The -m option runs a library module as a script which executes inside the main module prior to the execution of the main script". Really can't get my head around what you meant by 'prior to the execution of main script' at the end of the statement. I've tried looking all over the internet for this but can't get any explanation. Would be grateful if you could explain this to me. Thank in advance
    yehnan
    @yehnan
    Hi, Vikal, maybe try the official document: https://docs.python.org/3/using/cmdline.html
    Shivam Vikal
    @sunkgp
    @yehnan thank you for your reply. but the docs do not answer my specific query regarding what David meant by his statement in his book.
    David Beazley
    @dabeaz
    It looks like poor wording to me. The -m option basically runs a module (as would ordinarily be found using import) as the main program.
    Shivam Vikal
    @sunkgp
    @dabeaz I am glad you replied David. This was bothering me for quite some time now. This certainly makes it clear now.
    loneshark99
    @loneshark99
    I have been a long term c# developer but got into python and saw youtube video of David. Really great style of explaining concepts. I got the cookbook and have been learning a lot of new and intuitive way of doing stuff. Thank you David.
    Damian Shaw
    @damian_shaw_gitlab

    With all this discussion of annotations on Python dev I came up with this syntactically correct way of initializing variables in Python that dynamically applies the correct type at run time:

    foo: type(foo := 1)

    Of course 1 here could be a function call or any other expression you like. It made me think a lot about what exactly are annotations? And how PEP 563 changes them from the arbitrary expressions they are now to more glorified in-line doc strings. Not sure anyone else is thinking much about this, but this is where my brain has been for the last couple of days.