pydelhi / talks

Talks at Python Delhi User Group!
https://pydelhi.org/talks/
64 stars 52 forks source link

Proposal: Understanding strings in Python #77

Closed satwikkansal closed 6 years ago

satwikkansal commented 6 years ago

The talk is designed to give the audience a better insight of Python strings by first demonstrating them snippets with unexpected outcomes and then later diving into the concepts behind the outcomes.

Consider these snippets

    >>> a = "some_string" # first snippet
    >>> id(a)
    140420665652016
    >>> id("some" + "_" + "string")
    140420665652016

    >>> a = "foo" # second snippet
    >>> b = "foo"
    >>> a is b
    True

    >>> a = "foo!"
    >>> b = "foo!"
    >>> a is b
    False

    >>> 'a' * 20 is 'aaaaaaaaaaaaaaaaaaaa' # third snippet
    True
    >>> 'a' * 21 is 'aaaaaaaaaaaaaaaaaaaaa'
    False

These outcomes may seem baffling to some programmers at first, but all of them are consequences of how (native) string interning works in Python.

So there are 3 key things I’d be explaining in the talk one by one with the help of “examples and then explanation” approach:

  1. Strings are immutable sequences.
  2. String interning (which is possible because strings are immutable)
  3. Best ways for string concatenation (based on the knowledge of above two and some CPython optimizations)

And there are few more tricky snippets (related with concepts like “implicit string literal concatenation”, “backslashes in raw string literals”, etc) which I’ll be explaining at the end (if time allows).

aktech commented 6 years ago

@satwikkansal Thanks for the proposal. Will you be available for the talk on the meetup after the next on 17th Feb, 2017?

satwikkansal commented 6 years ago

Hey @aktech, 17th Feb is my college fest day (and it's kind of my last fest), can it be considered for the next available slot?

aktech commented 6 years ago

@satwikkansal Yes, sure it's up to you.

satwikkansal commented 6 years ago

Alright, I guess I'd prefer to wait for the next meetup then 😅

rajataaron commented 6 years ago

@satwikkansal are you available to deliver your talk on 14th April meetup?

satwikkansal commented 6 years ago

@rajataaron I'm afraid it won't be possible on 14th April.

satwikkansal commented 6 years ago

Can you please let me know the dates of next meetups? I guess it happens every alternate week, right?

rajataaron commented 6 years ago

You can check every possible date of our meetup here.

satwikkansal commented 6 years ago

Thanks, I can't make it to this one, but I'll definitely inform you at least a week before next meetup?

Pradhvan commented 6 years ago

This would be an interesting talk.

satwikkansal commented 6 years ago

Hey all, I'd love to have this session considered for upcoming meetups. Please let me know if there are slots available :)

rajataaron commented 6 years ago

Hi @satwikkansal you can choose a slot from 9th June and 7th July which feels right for you.

satwikkansal commented 6 years ago

9th June works

satwikkansal commented 6 years ago

If it's selected for 9th June, I'd appreciate a confirmation for the same :)

aktech commented 6 years ago

@satwikkansal Confirming this talk for 9th June 2018. Looking forward to it.

rajataaron commented 6 years ago

@satwikkansal as per the availability for 9th June I am putting you on schedule. You can check schedule here

satwikkansal commented 6 years ago

Location is Gurgaon, right?

satwikkansal commented 6 years ago

Never mind, just checked the event description, it's yet to be decided :+1:

rajataaron commented 6 years ago

Location is not confirmed yet @satwikkansal

utkarsh2102 commented 6 years ago

Hi @satwikkansal. We have your talk planned on this Saturday, 9th June. And the venue has been updated for the same. Details of the venue are as follows: Fueled Noida A-20, Block A, Sector-3, Noida The meetup will start at 11AM. Requesting you to be on time :) Also, please reply to this comment once acknowledged.

rajataaron commented 6 years ago

@CuriousLearner now you can close this issue. The talk has been delivered successfully.